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, 1 Unrelated Failure

As of commit 4af5078 with merge base 210047b (image):

NEW FAILURES - The following jobs have failed:

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.

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.

2 participants