Conversation
Add mapDivisibleMergeSplits after mapDivisibleSplits: for a Merge (e.g. merging reshape), when the merge output and merge outer input each have a divisible outer Split with the same factor, map the two outer IterDomains. Factor out isDivisible(Split*) for shared use with mapDivisibleSplits. Add IdModelTest.MergingReshapeOuterSplit_Mapped. Made-with: Cursor
|
!test |
Greptile SummaryThis PR extends
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["merge_outer (e.g. extent=4)"] --> M["[Merge]"]
B["merge_inner (e.g. extent=2)"] --> M
M --> C["merge_out (extent=8)"]
C --> SM["[split_merge]\nouter split, factor=2\nisDivisible ✓"]
SM --> SMO["split_merge->outer()\nextent=2"]
SM --> SMI["split_merge->inner()\nextent=4"]
A --> SO["[split_outer]\nouter split, factor=2\nisDivisible ✓"]
SO --> SOO["split_outer->outer()\nextent=2"]
SO --> SOI["split_outer->inner()\nextent=2"]
SMO <-.->|"mapDivisibleMergeSplits:\nsame factor + both divisible\n→ mapped in AlmostExact graph"| SOO
style SMO fill:#c8e6c9
style SOO fill:#c8e6c9
Reviews (2): Last reviewed commit: "Fix test" | Re-trigger Greptile |
| TEST_F(IdModelTest, MergingReshapeOuterSplit_Mapped) { | ||
| Fusion fusion; | ||
| FusionGuard fg(&fusion); | ||
|
|
||
| TensorView* in = makeContigConcreteTensor({2LL * 2, 2}); | ||
| fusion.addInput(in); | ||
| TensorView* out = reshape(in, {2LL * 2, 2}, {2LL * 2 * 2}); | ||
| fusion.addOutput(out); | ||
|
|
||
| in->outer_split(0, 2); | ||
| out->outer_split(0, 2); | ||
|
|
||
| IdModel id_model(&fusion); | ||
| const ValGraph& almost_exact_graph = id_model.buildAlmostExactGraph(); | ||
| EXPECT_TRUE(almost_exact_graph.disjointValSets().strictAreMapped( | ||
| in->axis(0), out->axis(0))); | ||
| } |
There was a problem hiding this comment.
Missing negative tests for
mapDivisibleMergeSplits
The PR adds one positive test (MergingReshapeOuterSplit_Mapped) but no negative counterparts exercising the guard conditions inside mapDivisibleMergeSplits. The following cases are silently assumed to not map, but are not explicitly verified:
- Inner split instead of outer split —
out->inner_split(0, 2)should NOT mapin->axis(0)andout->axis(0)(the!split_merge->innerSplit()guard). - Mismatched factors —
in->outer_split(0, 2)plusout->outer_split(0, 4)(different factors) should NOT map. - Non-divisible outer split — factors that don't evenly divide the dimension size should NOT map (the
isDivisibleguard).
The existing NonDivisibleSplits_NotMapped test covers mapDivisibleSplits, but there is no equivalent for mapDivisibleMergeSplits. Consider adding at least one negative test to document these invariants and prevent future regressions.
|
!test |
Summary
Adds
mapDivisibleMergeSplitstobuildAlmostExactGraph(), invoked aftermapDivisibleSplits. For a Merge (e.g. merging reshape), when the merge output and the merge\u0027s outer input each have a divisible outer Split with the same factor, the two outerIterDomains are mapped in the almost-exactValGraph.Also factors
isDivisible(Split*)out for reuse withmapDivisibleSplits.For #3987
Test
IdModelTest.MergingReshapeOuterSplit_Mapped: merging reshape{2*2,2} \u2192 {2*2*2}, matchingouter_split(0, 2)on input and output; assertsstrictAreMappedonin->axis(0)andout->axis(0).Made with Cursor