Skip to content

exir: Normalize constants before memory format conversion - #22901

Merged
zingo merged 2 commits into
pytorch:mainfrom
zingo:Normalize-constants-before-memory-format-conversion
Sep 19, 2026
Merged

zingo merged 2 commits into
pytorch:mainfrom
zingo:Normalize-constants-before-memory-format-conversion

Conversation

@zingo

@zingo zingo commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

The YOLO26 export graph transposes and unsqueezes its detection-anchor tensor. Folding can leave it as a lifted constant or buffer with shape [1, 2, N] and dim order [2, 0, 1]. torch.memory_format cannot represent that order, so MemoryFormatOpsPass can fail when rewriting its preserve-format copy.

----------------------- without fix with fix
input dim order [2, 0, 1] [2, 0, 1]
early normalization missing [0, 1, 2]
copy conversion assertion succeeds

Normalize lifted constants and buffers before MemoryFormatOpsPass. Treat non-persistent buffers as buffer inputs even though ExportedProgram stores their values in constants.

Cover both buffer storage modes and verify that to_edge keeps the caller-owned ExportedProgram unchanged.

cc @digantdesai @freddan80 @per @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani

The YOLO26 export graph transposes and unsqueezes its detection-anchor
tensor. Folding can leave it as a lifted constant or buffer with shape
[1, 2, N] and dim order [2, 0, 1]. torch.memory_format cannot
represent that order, so MemoryFormatOpsPass can fail when rewriting
its preserve-format copy.

                         without fix  with fix
input dim order          [2, 0, 1]    [2, 0, 1]
early normalization      missing      [0, 1, 2]
copy conversion          assertion    succeeds

Normalize lifted constants and buffers before MemoryFormatOpsPass.
Treat non-persistent buffers as buffer inputs even though
ExportedProgram stores their values in constants.

Cover both buffer storage modes and verify that to_edge keeps the
caller-owned ExportedProgram unchanged.

Signed-off-by: Zingo Andersen <Zingo.Andersen@arm.com>
Change-Id: Iee880f8c68d825a5016f34c05ecce955c3df2c61
@pytorch-bot

pytorch-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 9e8537d with merge base 3447ba9 (image):

NEW FAILURE - The following job has failed:

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

@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 Sep 17, 2026
@zingo zingo added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: exir Changes to any dialects and passes on these dialects, such as memory planning ciflow/trunk labels Sep 17, 2026
@zingo zingo changed the title Normalize constants before memory format conversion exir: Normalize constants before memory format conversion Sep 18, 2026
@mergennachin

Copy link
Copy Markdown
Contributor

FYI, the source-preservation test fails on the machine’s older PyTorch 2.13 because of shared constants dictionaries. It passes on the pinned 2.14

@zingo

zingo commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator Author

Fail seem unrelated.

@zingo
zingo merged commit 7a8e860 into pytorch:main Sep 19, 2026
601 of 604 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: exir Changes to any dialects and passes on these dialects, such as memory planning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants