-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Use IntLists rather than THLongStorage for sizes/strides for a number of functions in TH. #10209
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
|
NOTE: this is rebased on top of #10074 -- the right code to review is https://github.com/pytorch/pytorch/pull/10209/files/fde356244d98e4a10a1fd50a67429658b9eae788..HEAD |
|
|
||
| // Infers the size of a dim with size -1, if it exists. Also checks that new | ||
| // shape is compatible with the number of elements. | ||
| static std::vector<int64_t> infer_size(IntList shape, int64_t numel) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
ezyang
left a comment
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.
very nice
| namespace at { | ||
|
|
||
| static inline std::vector<int64_t> get_intlist_size_th(IntList sizes) { | ||
| if (sizes.size() == 0) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
… of functions in TH. This changes setStorage (called by set_), newView (view), and newWithStorage (tensor) as per the title. This also allows us to share size inference code between TH and ATen, so I killed e.g. newInferSize in TH; we just use at::infer_size inside of TH now. Finally, I reorganized the TH/THC tensor/storage code to more closely match up; e.g. if THC has a non-generic version of a function, TH will as well. NOTE: I didn't completely kill THSize, THStride yet because I haven't moved all the functions over yet. This has the unfortunate effect that we now have both IntList and Storage versions of the same concepts, e.g. there are IntListSize and IntListStride in Declarations.cwrap that pull out the LongStorage-ness, but not the 0-dim-to-1-dim or 0-dim-to-null functionality of THLongStorageView. Both of these limitations will be addressed in further PRs.
0efd854 to
3de86ca
Compare
facebook-github-bot
left a comment
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.
gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
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.
gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
Closing in favor of #10219. |
This changes setStorage (called by set_), newView (view), and newWithStorage (tensor) as per the title.
This also allows us to share size inference code between TH and ATen, so I killed e.g. newInferSize in TH; we just use at::infer_size inside of TH now.
Finally, I reorganized the TH/THC tensor/storage code to more closely match up; e.g. if THC has a non-generic version of a function, TH will as well.
NOTE: I didn't completely kill THSize, THStride yet because I haven't moved all the functions over yet. This has the unfortunate effect that we now have both IntList and Storage versions of the same concepts, e.g. there are IntListSize and IntListStride in Declarations.cwrap that pull out the LongStorage-ness, but not the 0-dim-to-1-dim or 0-dim-to-null functionality of THLongStorageView. Both of these limitations will be addressed in further PRs.