-
Notifications
You must be signed in to change notification settings - Fork 794
[slimtensor] Add SizesAndStrides and dimension utility functions for slimtensor usage #16384
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
base: gh/gasoonjia/75/base
Are you sure you want to change the base?
Conversation
…slimtensor usage This diff adds the `SizesAndStrides` class for efficiently storing tensor dimension sizes and strides, along with utility functions for computing element counts and storage requirements. **Key components:** 1. **`c10/macros/Macros.h`** - Branch prediction hint macros (`SLIMTENSOR_LIKELY/UNLIKELY`) for optimizing hot paths 2. **`util/ArrayRefUtil.h`** - Re-exports ExecuTorch's `ArrayRef`, `IntArrayRef`, and `makeArrayRef`; adds `toVec()` utility for converting ArrayRef to std::vector 3. **`c10/core/SizesAndStrides.h`** - Packed container for tensor sizes and strides: - Inline storage for tensors up to 5 dimensions (no heap allocation) - Out-of-line heap storage for larger tensors - Full copy/move semantics with proper resource management - Equality operators and iterators - `std::initializer_list` overloads for convenient initialization 4. **`util/SizeUtil.h`** - Size computation utilities: - `compute_numel()` - compute total number of elements - `compute_contiguous_strides()` - compute row-major contiguous strides - `compute_storage_nbytes()` / `compute_storage_nbytes_contiguous()` - compute storage byte requirements Differential Revision: [D89749336](https://our.internmc.facebook.com/intern/diff/D89749336/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/16384
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 145 PendingAs of commit cdb4b51 with merge base 41491c0 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
…ctions for slimtensor usage" This diff adds the `SizesAndStrides` class for efficiently storing tensor dimension sizes and strides, along with utility functions for computing element counts and storage requirements. **Key components:** 1. **`c10/macros/Macros.h`** - Branch prediction hint macros (`SLIMTENSOR_LIKELY/UNLIKELY`) for optimizing hot paths 2. **`util/ArrayRefUtil.h`** - Re-exports ExecuTorch's `ArrayRef`, `IntArrayRef`, and `makeArrayRef`; adds `toVec()` utility for converting ArrayRef to std::vector 3. **`c10/core/SizesAndStrides.h`** - Packed container for tensor sizes and strides: - Inline storage for tensors up to 5 dimensions (no heap allocation) - Out-of-line heap storage for larger tensors - Full copy/move semantics with proper resource management - Equality operators and iterators - `std::initializer_list` overloads for convenient initialization 4. **`util/SizeUtil.h`** - Size computation utilities: - `compute_numel()` - compute total number of elements - `compute_contiguous_strides()` - compute row-major contiguous strides - `compute_storage_nbytes()` / `compute_storage_nbytes_contiguous()` - compute storage byte requirements Differential Revision: [D89749336](https://our.internmc.facebook.com/intern/diff/D89749336/) [ghstack-poisoned]
…ctions for slimtensor usage" This diff adds the `SizesAndStrides` class for efficiently storing tensor dimension sizes and strides, along with utility functions for computing element counts and storage requirements. **Key components:** 1. **`c10/macros/Macros.h`** - Branch prediction hint macros (`SLIMTENSOR_LIKELY/UNLIKELY`) for optimizing hot paths 2. **`util/ArrayRefUtil.h`** - Re-exports ExecuTorch's `ArrayRef`, `IntArrayRef`, and `makeArrayRef`; adds `toVec()` utility for converting ArrayRef to std::vector 3. **`c10/core/SizesAndStrides.h`** - Packed container for tensor sizes and strides: - Inline storage for tensors up to 5 dimensions (no heap allocation) - Out-of-line heap storage for larger tensors - Full copy/move semantics with proper resource management - Equality operators and iterators - `std::initializer_list` overloads for convenient initialization 4. **`util/SizeUtil.h`** - Size computation utilities: - `compute_numel()` - compute total number of elements - `compute_contiguous_strides()` - compute row-major contiguous strides - `compute_storage_nbytes()` / `compute_storage_nbytes_contiguous()` - compute storage byte requirements Differential Revision: [D89749336](https://our.internmc.facebook.com/intern/diff/D89749336/) [ghstack-poisoned]
manuelcandales
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.
don't you need a test_array_ref_util.cpp as well?
…ctions for slimtensor usage" This diff adds the `SizesAndStrides` class for efficiently storing tensor dimension sizes and strides, along with utility functions for computing element counts and storage requirements. **Key components:** 1. **`c10/macros/Macros.h`** - Branch prediction hint macros (`SLIMTENSOR_LIKELY/UNLIKELY`) for optimizing hot paths 2. **`util/ArrayRefUtil.h`** - Re-exports ExecuTorch's `ArrayRef`, `IntArrayRef`, and `makeArrayRef`; adds `toVec()` utility for converting ArrayRef to std::vector 3. **`c10/core/SizesAndStrides.h`** - Packed container for tensor sizes and strides: - Inline storage for tensors up to 5 dimensions (no heap allocation) - Out-of-line heap storage for larger tensors - Full copy/move semantics with proper resource management - Equality operators and iterators - `std::initializer_list` overloads for convenient initialization 4. **`util/SizeUtil.h`** - Size computation utilities: - `compute_numel()` - compute total number of elements - `compute_contiguous_strides()` - compute row-major contiguous strides - `compute_storage_nbytes()` / `compute_storage_nbytes_contiguous()` - compute storage byte requirements Differential Revision: [D89749336](https://our.internmc.facebook.com/intern/diff/D89749336/) [ghstack-poisoned]
Stack from ghstack (oldest at bottom):
This diff adds the
SizesAndStridesclass for efficiently storing tensor dimension sizes and strides, along with utility functions for computing element counts and storage requirements.Key components:
c10/macros/Macros.h- Branch prediction hint macros (SLIMTENSOR_LIKELY/UNLIKELY) for optimizing hot pathsutil/ArrayRefUtil.h- Re-exports ExecuTorch'sArrayRef,IntArrayRef, andmakeArrayRef; addstoVec()utility for converting ArrayRef to std::vectorc10/core/SizesAndStrides.h- Packed container for tensor sizes and strides:std::initializer_listoverloads for convenient initializationutil/SizeUtil.h- Size computation utilities:compute_numel()- compute total number of elementscompute_contiguous_strides()- compute row-major contiguous stridescompute_storage_nbytes()/compute_storage_nbytes_contiguous()- compute storage byte requirementsDifferential Revision: D89749336