[PyTorch] RFC: optimize c10::optional<ArrayRef<T>>#59333
[PyTorch] RFC: optimize c10::optional<ArrayRef<T>>#59333swolchok wants to merge 12 commits intogh/swolchok/252/basefrom
Conversation
Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit 2d02790 (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
Pull Request resolved: #59333 Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. ghstack-source-id: 130402821 Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/)
|
If and when this is committed, we should leave a breadcrumb somewhere indicating that this is a thing that will regress when we upgrade to std::optional, and we'll need to port this optimization over. |
Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
Pull Request resolved: #59333 Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. ghstack-source-id: 130427769 Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D28843027/)!
|
Easy breadcrumb is add a static assert on |
| size_type Length; | ||
|
|
||
| void debugCheckNullptrInvariant() { | ||
| TORCH_INTERNAL_ASSERT( |
| "c10::optional<IntArrayRef> should be trivially copyable"); | ||
| static_assert( | ||
| sizeof(c10::optional<c10::IntArrayRef>) == sizeof(c10::IntArrayRef), | ||
| "c10::optional<IntArrayRef> should be size-optimized"); |
There was a problem hiding this comment.
This is assert is good, just shouldn't be in this file (because it's likely to get deleted when we go to std::optional)
There was a problem hiding this comment.
if people are going to delete this file without looking at it, what's going to stop them from deleting the contents of Optional.h or Optional_test.cpp without looking? (and which one of those two did you want this moved to)
There was a problem hiding this comment.
Blugh, IDK, some random test file in ATen/test maybe. Or we can just trust in code review, I guess.
| }; | ||
|
|
||
| // HACK: Optimization for ArrayRef<T>. We take advantage of an unused | ||
| // bit pattern in ArrayRef (inspirted by Arthur O'Dwyer's |
Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
…o on "[PyTorch] RFC: optimize c10::optional<ArrayRef<T>>" Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
Pull Request resolved: #59333 Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. ghstack-source-id: 130553181 Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D28843027/)!
…ize c10::optional<ArrayRef<T>>" Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
…nal<ArrayRef<T>>" Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
Pull Request resolved: #59333 Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. ghstack-source-id: 130623937 Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D28843027/)!
Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) [ghstack-poisoned]
Pull Request resolved: #59333 Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. ghstack-source-id: 130631329 Differential Revision: [D28843027](https://our.internmc.facebook.com/intern/diff/D28843027/) **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D28843027/)!
|
This pull request has been merged in 1798ff0. |
Summary: Pull Request resolved: pytorch#59333 Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. ghstack-source-id: 130631329 Test Plan: Updated optional_test and added static_assert in Optional.cpp. Reviewed By: ezyang Differential Revision: D28843027 fbshipit-source-id: 3029f05e03a9f04ca7337962e7770cdeb9a608d9
Summary: Pull Request resolved: pytorch#59333 Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers. ghstack-source-id: 130631329 Test Plan: Updated optional_test and added static_assert in Optional.cpp. Reviewed By: ezyang Differential Revision: D28843027 fbshipit-source-id: 3029f05e03a9f04ca7337962e7770cdeb9a608d9
Stack from ghstack:
Code comment should explain this in sufficient detail. In brief, making it 16 bytes should get it to be passed in registers.
Differential Revision: D28843027