Repository navigation
OpenVINO: transpose channels-last tensors at partition edges - #24797
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24797
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 4bad4d2 with merge base 2d8cd35 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes addressing channels-last tensor handling at OpenVINO partition boundaries.
No open issues 🎉
What changed in this PR
This PR fixes channels-last tensor handling at OpenVINO partition boundaries, addressing silent incorrect results in layout-sensitive operations.
Changes:
- Adds boundary transposes during lowering and maps runtime tensor shapes to and from memory order.
- Adds layout regression tests covering partition inputs, outputs, dynamic sizes, and size-one dimensions.
- Refactors input metadata collection and updates layout-related comments and type annotations.
| File | Description |
|---|---|
exir/tensor.py |
Corrects tuple annotations for strides and sizes. |
backends/openvino/tests/ops/test_dim_order.py |
Adds channels-last boundary regression tests. |
backends/openvino/tests/ops/test_copy.py |
Updates the comment explaining partition-internal copies. |
backends/openvino/tests/ops/base_openvino_op_test.py |
Allows tests to specify dynamic shapes during export. |
backends/openvino/runtime/OpenvinoBackend.cpp |
Maps tensor shapes between logical and memory order and validates output rank. |
backends/openvino/preprocess.py |
Collects input layout metadata and inserts boundary transposes. |
backends/openvino/partitioner.py |
Updates comments to reflect the new layout handling. |
Review effort: Balanced
|
@claude review effort=max |
|
Claude finished @shoumikhin's task in 31m 46s —— View job PR Review: #24797This PR adds transposes at channels-last OpenVINO partition edges, but the runtime now binds every blob in memory order with no version marker, so some older Detailed reviewSummaryPreprocess now adds a Problems found:
Nothing was executed, because this runner can't run Python, pytest or Code Quality
Testing
API Design
Backward Compatibility
Performance
Specific Comments
RecommendationNeeds Discussion The open question is whether OpenVINO
Fix the README and the test assertions in this PR. The rest are minor. Review tasks
|
This PR needs a
|
|
Thanks for the review. Addressed the comments in the latest commit.
|
|
@claude review effort=max |
|
Claude finished @shoumikhin's task in 37m 41s —— View job PR Review: #24797The runtime now passes sizes in memory order for every edge that is not in the default dim order, but nothing in the blob says whether it was lowered with the new transposes, so existing Detailed reviewSummaryThis PR adds a transpose, when lowering, to each OpenVINO partition input and output that is not in the default dim order, and the runtime now passes their sizes in memory order. This re-review covers d691c32.
I couldn't run Python or the tests on this runner, so everything below comes from reading the code. Testing
API Design
Backward Compatibility
Specific Comments
RecommendationRequest Changes
Review tasks
|
There was a problem hiding this comment.
🟡 Changes recommended
A critical compatibility issue silently corrupts legacy channels-last dynamic output shapes by treating logical dimensions as memory order without versioning or rejecting incompatible layouts.
1 open issue
Review effort: Balanced
|
Thanks for the review. Added a header to distinguish between old .pte and new and kept the same behaviour for old pte's |

Summary
OpenVINO computes in the default dim order. When a partition input or output was channels-last, it read or wrote the bytes as if they were contiguous, and ExecuTorch returned wrong values without any error. Elementwise ops hide this, since they produce the same bytes either way, so it showed up mostly with reductions, convs and other ops that depend on the layout.
The lowering now adds a convert_layout transpose for each partition input and output in another dim order. The runtime passes OpenVINO the sizes in memory order, both when it binds tensors and when it resizes dynamic outputs. Copies used only inside a partition can now stay there for OpenVINO to fold.
Added a new method _partition_inputs to keep preprocess under flake8's complexity limit.
Test plan
Added a new test for testing non-default dim order. Each new edge case in test_dim_order fails without the fix, with wrong values and no error. With the fix everything is passing. Also checked with the reproducer in #24325 under 13. The reproducer now works without errors.