Skip to content

Add at::optional from https://github.com/akrzemi1/Optional#5530

Merged
colesbury merged 5 commits intopytorch:masterfrom
colesbury:optional
Mar 5, 2018
Merged

Add at::optional from https://github.com/akrzemi1/Optional#5530
colesbury merged 5 commits intopytorch:masterfrom
colesbury:optional

Conversation

@colesbury
Copy link
Copy Markdown
Member

This adds at::optional which matches the API of std::optional from C++17. For details about the implementation, see https://github.com/akrzemi1/Optional.

I've moved the types from std::experimental to the at namespace. This seems less likely to cause conflicting definitions, especially since PyTorch symbols are currently loaded with RTLD_GLOBAL.

I've verified that it compiles, but I haven't added any uses as part of this PR. I plan to use internally within ATen to implement reshape. We may also want to use it in place of undefined tensors in the public API.

Copy link
Copy Markdown
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider also leaving a URL breadcrumb to upstream

@gchanan
Copy link
Copy Markdown
Contributor

gchanan commented Mar 2, 2018

roughly how do you plan to use it for reshape?

@colesbury
Copy link
Copy Markdown
Member Author

colesbury commented Mar 2, 2018

@gchanan reshape needs to compute the strides of the reshaped tensor. It's convenient to implement this as a function that returns optional<vector<int64_t>>, since it may not succeed.

@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Mar 5, 2018

@pytorchbot retest this please

1 similar comment
@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Mar 5, 2018

@pytorchbot retest this please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants