Write golden input artifacts in the tensor's own byte order - #21851
Merged
Conversation
_dump_golden_artifacts wrote inputs through contiguous(), which means contiguous_format and re-lays a channels_last tensor back to NCHW. The .bin then disagrees with the dim_order the accompanying .pte declares, and the runtime ingests it as a raw memcpy, so anything replaying a golden input against the program feeds it transposed data. Permuting by dim_order() first writes the bytes the runtime consumes. It is a no-op for a contiguous tensor, which is what every flow in the suite feeds today: all of its inputs are torch.randn and friends, and the permutes and transposes are inside the models rather than in the inputs. Outputs deliberately keep contiguous(). reference_output is the eager result, so a model ending in a permute hands back a view whose dim_order describes the source rather than the result, while the program materializes that output contiguously. Permuting there would write the pre-permute values and corrupt the goldens for the permute and transpose operator tests, which is what the new test for that case pins down. Nothing consumes the channels_last path yet. The Cortex-M flow is the first to hand the harness such inputs, and CI uploads these artifacts, so this is a prerequisite for it. Authored with Claude Code.
This PR needs a
|
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21851
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 6 PendingAs of commit 9597db3 with merge base 5c3cb65 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
digantdesai
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_dump_golden_artifacts wrote inputs through contiguous(), which means contiguous_format and re-lays a channels_last tensor back to NCHW. The .bin then disagrees with the dim_order the accompanying .pte declares, and the runtime ingests it as a raw memcpy, so anything replaying a golden input against the program feeds it transposed data.
Permuting by dim_order() first writes the bytes the runtime consumes. It is a no-op for a contiguous tensor, which is what every flow in the suite feeds today: all of its inputs are torch.randn and friends, and the permutes and transposes are inside the models rather than in the inputs.
Outputs deliberately keep contiguous(). reference_output is the eager result, so a model ending in a permute hands back a view whose dim_order describes the source rather than the result, while the program materializes that output contiguously. Permuting there would write the pre-permute values and corrupt the goldens for the permute and transpose operator tests, which is what the new test for that case pins down.
Test plan
Nothing consumes the channels_last path yet. The Cortex-M flow is the first to hand the harness such inputs, and CI uploads these artifacts, so this is a prerequisite for it.
Authored with Claude Code.