[C++ API] Use torch::Tensor instead of at::Tensor/Variable mix#8680
Merged
goldsborough merged 2 commits intopytorch:masterfrom Jun 25, 2018
Merged
[C++ API] Use torch::Tensor instead of at::Tensor/Variable mix#8680goldsborough merged 2 commits intopytorch:masterfrom
goldsborough merged 2 commits intopytorch:masterfrom
Conversation
ezyang
approved these changes
Jun 20, 2018
Contributor
ezyang
left a comment
There was a problem hiding this comment.
Sure why not. Downstream is aware and OK with this change?
Contributor
Author
Contributor
|
That's great! Just to clarify, the |
Contributor
|
Nice! This looks good to me, I'm only wondering about |
Contributor
Author
|
@jgehring Ideally we'd have overloads for these methods that take an |
da29c0f to
b7514bf
Compare
b7514bf to
609c67a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR creates a
namespace torch { using Tensor = autograd::Variable; }typedef and uses this type exclusively instead of the current mix ofat::Tensorandautograd::Variable. This is so that users only shall seetorch::Tensorand not be aware (largely) ofat::Tensor.Mostly this PR then codemods the C++ API. Complications arose in:
torch::Tensor) instead ofat::Tensors,at::Tensor,TensorRange, which copies a range oftorch::Tensors into a vector ofat::Tensor, and then converts implicitly to anArrayRef<at::Tensor>. This is to support calling functions likeat::stack()with a vector oftorch::Tensor, which is currently not possible sincevector<Variable>is unrelated tovector<Tensor>in C++.One small caveat: ambiguity arises around
Tensorwhen you dousing namespace torch, but if anything that's a reason not to use such blanket using directives.@jgehring could you look at serialization stuff (Or raise any other general concerns)?
@ebetica @ezyang @apaszke