[Relax] Fix RemoveUnusedParameters symbolic var promotion - #19901
Conversation
After the tirx refactor, a relax `PrimType` parameter carries only a dtype and no longer binds a value, so it does not *define* the symbolic variable it used to provide. When `RemoveUnusedParameters` drops an unused tensor parameter whose shape is the sole definition of a free symbolic variable, it re-adds that variable through a value-bearing `PrimType` (`R.Prim(value=...)`) parameter. Under the stricter tirx well-formedness verifier this leaves the variable undefined, so the pass emits an ill-formed module. Promote each such free symbolic variable through a 1-D `ShapeType` parameter (`R.Shape([var])`) instead, which actually defines the variable, and pass its value at the call site as a `ShapeExpr`. The previously xfail-ing `test_replace_symbolic_variables` is updated to the new shape-based form and re-enabled as a regression test.
There was a problem hiding this comment.
Code Review
This pull request updates the remove_unused_parameters pass to promote free symbolic variables via 1-D shape parameters instead of PrimType parameters, which resolves issues with undefined variables under the strict tirx verifier. Feedback on the changes points out that ShapeType does not carry or define symbolic variables; instead, ShapeStructInfo should be used to ensure the symbolic variables are properly defined and recognized by the well-formedness verifier.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
After the tirx refactor, a relax
PrimTypeparameter carries only adtype and no longer binds a value, so it does not define the symbolic
variable it used to provide. When
RemoveUnusedParametersdrops anunused tensor parameter whose shape is the sole definition of a free
symbolic variable, it re-adds that variable through a value-bearing
PrimType(R.Prim(value=...)) parameter. Under the stricter tirxwell-formedness verifier this leaves the variable undefined, so the pass
emits an ill-formed module.
Promote each such free symbolic variable through a 1-D
ShapeTypeparameter (
R.Shape([var])) instead, which actually defines thevariable, and pass its value at the call site as a
ShapeExpr. Thepreviously xfail-ing
test_replace_symbolic_variablesis updated to thenew shape-based form and re-enabled as a regression test.