Skip to content

Conversation

@Gasoonjia
Copy link
Contributor

@Gasoonjia Gasoonjia commented Dec 24, 2025

Stack from ghstack (oldest at bottom):

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

…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]
@pytorch-bot
Copy link

pytorch-bot bot commented Dec 24, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/16385

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures, 5 Unrelated Failures

As of commit 55d69cd with merge base 9ba1b5d (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Gasoonjia added a commit that referenced this pull request Dec 24, 2025
…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-source-id: 331051343
Pull Request resolved: #16385
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 24, 2025
@github-actions
Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

…d 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]
Gasoonjia added a commit that referenced this pull request Dec 26, 2025
…operation

Pull Request resolved: #16385

**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
ghstack-source-id: 331187116
@exported-using-ghexport

Differential Revision: [D89750150](https://our.internmc.facebook.com/intern/diff/D89750150/)
…d 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]
…d 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]
Gasoonjia added a commit that referenced this pull request Jan 9, 2026
…operation

Pull Request resolved: #16385

**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
ghstack-source-id: 332731275
@exported-using-ghexport

Differential Revision: [D89750150](https://our.internmc.facebook.com/intern/diff/D89750150/)
…d 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]
Gasoonjia added a commit that referenced this pull request Jan 9, 2026
…operation

Pull Request resolved: #16385

**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
ghstack-source-id: 332735712
@exported-using-ghexport

Differential Revision: [D89750150](https://our.internmc.facebook.com/intern/diff/D89750150/)
…d 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]
Gasoonjia added a commit that referenced this pull request Jan 12, 2026
…operation

Pull Request resolved: #16385

**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
ghstack-source-id: 332983722
@exported-using-ghexport

Differential Revision: [D89750150](https://our.internmc.facebook.com/intern/diff/D89750150/)
@meta-codesync meta-codesync bot merged commit 6b137ae into gh/gasoonjia/76/base Jan 12, 2026
166 of 175 checks passed
@meta-codesync meta-codesync bot deleted the gh/gasoonjia/76/head branch January 12, 2026 22:23
Gasoonjia added a commit that referenced this pull request Jan 12, 2026
…operation (#16550)

This PR was created by the merge bot to help merge the original PR into
the main branch.
ghstack PR number: #16385 by
@Gasoonjia
^ Please use this as the source of truth for the PR details, comments,
and reviews
ghstack PR base:
https://github.com/pytorch/executorch/tree/gh/gasoonjia/76/base
ghstack PR head:
https://github.com/pytorch/executorch/tree/gh/gasoonjia/76/head
Merge bot PR base:
https://github.com/pytorch/executorch/tree/gh/gasoonjia/75/orig
Merge bot PR head:
https://github.com/pytorch/executorch/tree/gh/gasoonjia/76/orig
Differential Revision:
[D89750150](https://our.internmc.facebook.com/intern/diff/D89750150/)
@diff-train-skip-merge

---------

Co-authored-by: gasoonjia <[email protected]>
Co-authored-by: Gasoonjia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants