fix(pass): preserve dynamic-shape Var pointer identity in InitMemRef#979
Conversation
…w-native-sys#970) InitMemRef's ProcessNormalVar was creating new Var objects for non-shaped types (e.g. ScalarType INDEX for dynamic dimensions like M, N) even though they don't need MemRef initialization. This fragmented Var pointers: a single M shared across param types, return types, and body became 4 distinct pointers after the pass. Fix by returning the original Var for non-ShapedType variables, and remove the last Variable pointer mismatch suppression from RoundtripInstrument — all roundtrip checks now run with zero suppressions. Closes hw-native-sys#970
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughFixes a bug where the InitMemRef pass was fragmenting dynamic-shape Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request addresses the "Variable pointer mismatch" issue by ensuring that non-shaped types, such as those used for dynamic-shape dimensions, preserve their pointer identity during IR mutations in InitMemRefMutator. By returning the original Var instead of creating a new one for these types, structural equality checks no longer fail due to pointer bijections. Consequently, the previous workarounds and documentation regarding this limitation in the RoundtripInstrument have been removed. I have no feedback to provide.
Summary
Closes #970
InitMemRef::ProcessNormalVarwas creating newVarobjects for non-ShapedType variables (e.g.ScalarType(INDEX)for dynamic dimensions likeM,N) even though they don't need MemRef initialization. This fragmented a single sharedMpointer into 4 distinct pointers across param types, return types, and body — breakingstructural_equalbijection during roundtrip checks.Fix: return the original
Varfor non-ShapedType variables. This also removes the lastVariable pointer mismatchsuppression fromRoundtripInstrument— all roundtrip checks now run with zero suppressions.Test plan