Repository navigation
BundleIO: Preserve channels-last input and output layouts - #23482
Erik-Lundell wants to merge 4 commits into
Conversation
TensorSpec.from_tensor(..., const=True) makes test tensors contiguous, discarding channels-last strides and reordering their bytes. Bundled inputs can then have incorrect values, while output verification can fail its stride check. Preserve the layout of bundled test tensors. Construct ATen tensors with strides derived from the serialized dimension order before copying their bytes. Cover channels-last inputs and outputs, offset views, and non-dense views. Additionally, a small type hint fix in tensor.py Validation: bundled-program suite (10 tests) Signed-off-by: Erik Lundell <erik.lundell@arm.com> Change-Id: I4d05a144aafbb0fbd25bfbbd161c4eebc8dc2b0f
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23482
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 1 PendingAs of commit ded0066 with merge base aee0a33 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
🟡 Changes recommended
The updated dim_order_from_stride signature retains an incorrect return type contract.
1 open finding
What changed in this PR
Preserves bundled tensor layouts so channels-last inputs and outputs serialize and load correctly.
Changes:
- Adds layout-preserving tensor serialization.
- Reconstructs ATen tensors using serialized dimension-order strides.
- Adds coverage for channels-last tensors and views.
| File | Description |
|---|---|
extension/pybindings/test/test_pybindings.py |
Adds end-to-end channels-last bundle verification. |
exir/tests/test_tensor.py |
Tests layout-preserving TensorSpec creation. |
exir/tensor.py |
Adds optional layout preservation. |
devtools/bundled_program/test/test_bundle_data.py |
Tests serialized layouts and view data. |
devtools/bundled_program/core.py |
Preserves bundled input/output layouts. |
devtools/bundled_program/bundled_program.cpp |
Reconstructs tensors with serialized strides. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| def dim_order_from_stride( | ||
| stride: Tuple[int], sizes: Optional[Tuple[int]] = None | ||
| stride: Tuple[int, ...], sizes: Optional[Tuple[int, ...]] = None |
|
Hi @rascani and @digantdesai this is in the general code and need a non Arm review :) |
|
@Gasoonjia - do you think you could take a look? |
|
@claude - Review this PR. |
|
Claude finished @rascani's task in 1m 22s —— View job PR Review: #23482Summary: Bundled test tensors now keep their eager strides, so channels-last inputs and outputs load correctly. However, any dense non-contiguous expected output (for example the result of Detailed reviewBackward Compatibility
API Design
Testing
RecommendationRequest Changes. The arbitrary-permutation regression should be fixed before merge. The channels-last fix itself is correct. |
|
Sorry, this is not quite ready |
|
Yeah I was overrideing @Erik-Lundell s origina draft as I needed part of this fix for something else and undrafted sorry for the extra work. |
|
Replaced with this #23927 |

TensorSpec.from_tensor(..., const=True) makes test tensors contiguous, discarding channels-last strides and reordering their bytes. Bundled inputs can then have incorrect values, while output verification can fail its stride check.
Preserve the layout of bundled test tensors. Construct ATen tensors with strides derived from the serialized dimension order before copying their bytes.
Cover channels-last inputs and outputs, offset views, and non-dense views.
Additionally, a small type hint fix in tensor.py
cc @Gasoonjia @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani