You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update base for Update on "[slimtensor] Add SlimTensor class with basic properties and CPU copy operation"
**Key components:**
1. **`c10/core/Contiguity.h`** - Contiguity checking utility:
- `_compute_contiguous<T>()` - computes whether a tensor with given sizes/strides is contiguous in memory (row-major order)
2. **`core/SlimTensor.h`** - Main SlimTensor class with:
- **Constructors**: Default (undefined tensor) and full constructor with storage, sizes, strides, dtype, and storage_offset
- **Property accessors**:
- `sizes()`, `size(dim)` - get tensor dimensions with negative indexing support
- `strides()`, `stride(dim)` - get tensor strides with negative indexing support
- `dtype()`, `device()`, `device_type()`, `device_index()`
- `numel()`, `dim()`, `nbytes()`, `itemsize()`
- `data_ptr()` - returns pointer to tensor data (adjusted for storage_offset)
- `storage_offset()`, `storage()`
- **State queries**: `defined()`, `is_cpu()`, `is_contiguous()`, `is_empty()`
- **Copy operation**: `copy_(other)` - copies data from another tensor
- Fast path: uses memcpy for both-contiguous tensors
- Slow path: element-wise copy respecting strides for non-contiguous tensors
- **Setters**: `reset()`, `set_storage()`, `set_sizes_and_strides()`
**Curretnt constraints:**
- Only CPU device supported
- Only Float32 dtype tested
- copy_() only supports CPU-to-CPU copy
Those contraints will be further improved in the following diffs
Differential Revision: [D89750150](https://our.internmc.facebook.com/intern/diff/D89750150/)
[ghstack-poisoned]
0 commit comments