tvm_tirx.tirx.transform.ConvertSSA#
- tvm_tirx.tirx.transform.ConvertSSA()#
Give every variable definition in an IRModule a distinct identity.
This pass handles cases where the same tirx.Var appears in multiple functions within the same module. For example, after extracting a fragment from one function into another, where the same tirx.Var may be defined both as within the body of the original function, and as a parameter within the hoisted function.
- Returns:
fpass (tvm_tirx.ir.transform.Pass) – The result pass
Examples
The input uses explicit
T.Bindstatements to reuse a variable and disables the SSA check. Ordinary parsed assignments create distinct variable bindings.import tvm_tirx as tvm from tvm_tirx.script import ir as I, tirx as T from tvm_tirx.tirx import transform as tr v = T.dynamic("v", "int32") @I.ir_module(check_well_formed=False) class Before: @T.function(private=True) def main(): T.Bind(v, 16) T.evaluate(v) T.Bind(v, 32) T.evaluate(v) @I.ir_module class Expected: @T.function(private=True) def main(): v = 16 T.evaluate(v) v_1 = 32 T.evaluate(v_1) def run_pass(): return tr.ConvertSSA()(Before) tvm.ir.assert_structural_equal(run_pass(), Expected)