Arm backend: Add aten.flip support via TOSA REVERSE#20592
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20592
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 32 PendingAs of commit 6882925 with merge base d03dee5 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
This PR needs a
|
| exir_op = "executorch_exir_dialects_edge__ops_aten_flip_default" | ||
|
|
||
| input_t1 = Tuple[torch.Tensor] # Input x | ||
|
|
There was a problem hiding this comment.
Would be nice with coverage for dims=[]
|
Thanks for the nice patch! |
|
@claude does the new files in this PR need to be added to any buck2 files? |
|
Claude finished @zingo's task in 1m 19s —— View job Do the new files need buck2 (TARGETS) updates?Short answer: only the test file. The two new source files are already covered by globs, but Details:
The modified files ( Required changeIn "ops/test_exp.py",
"ops/test_fft.py",
+ "ops/test_flip.py",Note the passes tests are globbed ( Note I made this change locally but couldn't push it — the branch's |
zingo
left a comment
There was a problem hiding this comment.
Thanks this will be Ok to merge after the backends/arm/test/targets.bzl is updated (see comments) and extra nice if you also add a test case but that can be fixed later also :)
| @@ -0,0 +1,207 @@ | |||
| # Copyright 2026 Arm Limited and/or its affiliates. | |||
There was a problem hiding this comment.
This should probably be added to backends/arm/test/targets.bzl see claude comment for more info :)
flip was staged as supported (quantizer, EthosU55NotSupported, InsertDataLayoutCastsPass) but had no lowering, so it fell back to CPU. TOSA REVERSE reverses a single axis, while aten.flip can take several: - DecomposeFlipPass rewrites a multi-axis flip into a chain of single-axis flips, run after Q/DQ folding so each inherits the shared quant params. - FlipVisitor lowers each single-axis flip to one REVERSE (axis = dim % rank). - aten.flip.default is added to the INT and FP support lists so it delegates. U55 and U65 are unchanged: their TOSA subset has no REVERSE. Signed-off-by: Youngsik Yang <vacu9708@gmail.com>
zingo
left a comment
There was a problem hiding this comment.
Super thanks!
I approved it but lets the tests run just to make sure then you can merge. If you can't let me know and Ill merge this for you.
|
All test passer the test-qnn-.. . Is unrelated and fails in other PRs also. |
|
Thanks for the quick review and for kicking off the extra CI, @zingo! Both review points have been addressed.
I don't have merge access, can you please merge it if there are no more issues? |
Summary
TOSA
REVERSEreverses a single axis, whileaten.flipcan take several. A multi-axis flip is a chain of single-axis reversals, so:DecomposeFlipPassrewrites a multi-axis flip into single-axis flips (one dim passes through, zero dims is a no-op).FlipVisitorlowers each single-axis flip to oneREVERSE(axis = dim % rank).graph TD src["aten.flip(x, [d0, d1, d2])"] src -->|DecomposeFlipPass| F0 subgraph flips["FX graph"] direction LR F0["aten.flip [d0]"] --> F1["aten.flip [d1]"] --> F2["aten.flip [d2]"] end subgraph reverses["Serialized TOSA"] direction LR R0["REVERSE axis=d0"] --> R1["REVERSE axis=d1"] --> R2["REVERSE axis=d2"] end F0 -.FlipVisitor.-> R0 F1 -.FlipVisitor.-> R1 F2 -.FlipVisitor.-> R2Changes
I referred to existing ops for each new file:
op_permute.pyforop_flip.py,decompose_strided_slice_copy_passfordecompose_flip_pass.py, andtest_permute.pyfortest_flip.py._passes/decompose_flip_pass.py(new)DecomposeFlipPassoperators/op_flip.py(new)FlipVisitor_passes/__init__.pyDecomposeFlipPass_passes/arm_pass_manager.pyDecomposeFlipPassin the post-fold decompose stageoperators/__init__.pyop_flipoperator_support/tosa_profile_supported_op_lists.pyaten.flip.defaultto the INT and FP support liststest/ops/test_flip.py(new)Testing
tosa_FPtorch.fliptosa_FP_reverse_countREVERSEper flipped dimtosa_FP_bf16torch.fliptosa_FP_fp8torch.flipbool_tosa_FPtorch.flipon a bool masktosa_INTtorch.flip16a8w_tosa_INTtorch.flipu55_INT_not_delegatedREVERSE)u85_INTvgf_no_quant,vgf_quantcc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani