-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Implement a constructor for nested_tensor that is similar to torch.tensor() #88213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/88213
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 76704c9: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
This pull request was exported from Phabricator. Differential Revision: D40878312 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these changes needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler started complaining for some reason.
torch/csrc/utils/nested.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to rely on _nested_tensor_from_tensor_list for all the dtype, device, etc. checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the implementation for both torch::tensor() and _nested_tensor_from_tensor_list, we do the same amount of checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but this could deduplicate code
|
This pull request was exported from Phabricator. Differential Revision: D40878312 |
2587a6b to
3eb62e7
Compare
3eb62e7 to
d6e8c1d
Compare
|
This pull request was exported from Phabricator. Differential Revision: D40878312 |
d6e8c1d to
a29a8ce
Compare
|
This pull request was exported from Phabricator. Differential Revision: D40878312 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't think you should need this check
>>> torch.nested.nested_tensor([])
nested_tensor([
])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for the C++ path, given that python now takes python vars it needs different impls (or at least torch::tensor does so)
f2663fb to
ad8093d
Compare
|
This pull request was exported from Phabricator. Differential Revision: D40878312 |
ad8093d to
22c0bd9
Compare
22c0bd9 to
63b2250
Compare
|
This pull request was exported from Phabricator. Differential Revision: D40878312 |
torch/nested/__init__.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: when using _add_docstr, in order to render the arguments for the function a line containing the signature of the function needs to be added here (see to_padded_tensor above for an example)
(the preview for the docs is available under helpful links in the pytorch-bot comment on this PR if you would like to look at the rendering!)
63b2250 to
4270b59
Compare
|
This pull request was exported from Phabricator. Differential Revision: D40878312 |
1 similar comment
|
This pull request was exported from Phabricator. Differential Revision: D40878312 |
4270b59 to
d7a8c00
Compare
…nsor() (pytorch#88213) Summary: Pull Request resolved: pytorch#88213 This diff merges both previous implementations of constructors for nested tensors, the one from lists of tensors and the one with arbitrary python lists, adn implements it in pytorch core so no extensions are needed to construct NT. Test Plan: All nested tensor tests pass successfully. Specifically: `buck test mode/dev-nosan //caffe2/test:nested` Reviewed By: cpuhrsch, mikekgfb Differential Revision: D40878312 fbshipit-source-id: e9f36fa66287299efc144c45b65a8f6cbe248ca3
|
This pull request was exported from Phabricator. Differential Revision: D40878312 |
d7a8c00 to
76704c9
Compare
|
@pytorchbot merge -g |
Merge failedReason: This PR has internal changes and must be landed via Phabricator Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -g |
Merge startedYour change will be merged once all checks on your PR pass since you used the green (-g) flag (ETA: 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…nsor() (pytorch#88213) Summary: This diff merges both previous implementations of constructors for nested tensors, the one from lists of tensors and the one with arbitrary python lists, adn implements it in pytorch core so no extensions are needed to construct NT. Pull Request resolved: pytorch#88213 Approved by: https://github.com/cpuhrsch
Summary: This diff merges both previous implementations of constructors for nested tensors, the one from lists of tensors and the one with arbitrary python lists, adn implements it in pytorch core so no extensions are needed to construct NT.