Commit 2d53e6a
authored
[Unity][Transform] Handle replacement at both var binding and usage (#16367)
Resolve a bug that caused undefined relax variables in the output of
`CanonicalizeBindings` for cases where `VisitVarDef(const Var&)`
replaces a variable, and `VisitExpr_(const VarNode*)` returns a value
with different struct info, both occurring within the same
`VarBinding`.
The ExprMutator is only allowed to update a variable's struct info
if the value bound to it has new struct info. When
CanonicalizeBindings replaces a trivial binding, this may provide
better struct info as a result.
Prior to this commit, `ExprMutator::ReEmitBinding` defined a
remap for `binding->var->vid`, even if the derived class defined a
replacement by overriding `VisitVarDef`. If the derived class
defines a new variable binding by overriding `VisitVarDef`, and
also causes a variable replacement by overriding `VisitExpr` and
returning a type with different struct info, then `ExprMutator`
must check for both `binding->var->vid` *AND* `new_var->vid`. The
former may be present in the unmodified graph, and the latter may
be produced by the derived class before delegating to the base
class.
This commit updates `ExprMutator::ReEmitBinding` to define entries for
both replacements that may be required.1 parent 1e95b63 commit 2d53e6a
File tree
2 files changed
+133
-55
lines changed- src/relax/ir
- tests/python/relax
2 files changed
+133
-55
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
| 685 | + | |
685 | 686 | | |
| 687 | + | |
686 | 688 | | |
687 | 689 | | |
688 | 690 | | |
| |||
0 commit comments