Skip to content

[Relax] Fix RemoveUnusedParameters symbolic var promotion - #19901

Merged
tlopex merged 1 commit into
apache:mainfrom
MasterJH5574:relax-remove-unused-params-shapetype
Jun 29, 2026
Merged

[Relax] Fix RemoveUnusedParameters symbolic var promotion#19901
tlopex merged 1 commit into
apache:mainfrom
MasterJH5574:relax-remove-unused-params-shapetype

Conversation

@MasterJH5574

Copy link
Copy Markdown
Contributor

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.

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/relax/transform/remove_unused_parameters.cc
@tlopex
tlopex merged commit 3e355ad into apache:main Jun 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants