Transforms: make layout-copy rewrites backend-configurable - #22375
Transforms: make layout-copy rewrites backend-configurable#22375rascani wants to merge 5 commits into
Conversation
|
It seems like the patch is doing some things that are not that well advertised, why is test_mixed_reconvergence_fork_does_not_strand_a_permute removed and why is the new _maybe_distribute_upwards_permute_over_elementwise required just to support backend defined layout copies? |
8158e2d to
6e404f7
Compare
6e404f7 to
4bc4208
Compare
Agreed, sorry again about that. I have updated the summary to go in-depth and provided a review order suggestion. Upward distribution is not required to support backend-defined layout copies, and the unrestricted version can increase the copy count. I removed it from this PR and restored the mixed-reconvergence xfail. I also removed boundary compensation and the output-layout policy for the same reason. |
4bc4208 to
94d6f0b
Compare
The existing view and permute optimizers assumed that every layout change used the ATen permute target. Backends with a graph-visible layout dialect therefore could not reuse propagation or region cancellation without changing the operator family mid-rewrite. Make permute targets, emitted targets, fusion scope, propagation barriers, and output-boundary compensation explicit extension points while preserving existing defaults. Keep synthesized nodes in their source dialect, refresh their metadata, reject mixed-dialect chains conservatively, and cover reconvergent and rank-changing regions. AI-assisted: Codex.
Restore the shared mixed-reconvergence xfail and document that upward distribution is a backend opt-in because it can increase layout-copy count. AI-assisted: Codex.
Track each cancellation region's source permute target so constant and output compensation cannot silently switch dialects. Document why propagation excludes aliasing view.default and why backend policy hooks are opt-in. AI-assisted: Codex.
Keep this stack focused on preserving configured layout-copy dialects and stopping cancellation at backend barriers. Remove upward distribution and output-boundary compensation because either can increase the number of copies, and drop the unused noncontiguous-formation override. Preserve the existing aten.view.default behavior so alias handling can be reviewed separately with a dedicated reproducer. AI-assisted: Codex.
Drop the unrelated transpose-pair guard and the general lower-rank constant reorder fix. Retain only the dialect, metadata, barrier, and region-cancellation behavior consumed by Cortex-M explicit layout. AI-assisted: Codex.
94d6f0b to
57e4816
Compare
Summary
The layout propagation passes currently assume every layout copy is
aten.permute_copy. That prevents a backend from using the shared propagation algorithms when its layout copies must remain visible as a backend-specific operator.This PR separates the shared transformation mechanics from that backend policy:
permute_targetsdefines a closed set of operators representing layout copies.can_propagatelets a backend stop movement at barriers without adding backend-specific operators to the shared pass.Existing callers retain the current defaults. In particular, this PR does not add multi-input upward distribution, boundary compensation, or output-layout policy, and it does not change the handling of
aten.view.default. Those decisions are not required to support backend-defined layout-copy operators.Review guide
canonicalize_view_copy_permute_pass.pyandpermute_view_meta.pypropagate_view_copy_permute_pass.pyremove_permutes_around_elementwise_ops.pyAI-assisted: Codex.
Stack created with GitHub Stacks CLI • Give Feedback 💬
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell