tvm_tirx.tirx.transform.RemoveNoOp

Contents

tvm_tirx.tirx.transform.RemoveNoOp#

tvm_tirx.tirx.transform.RemoveNoOp()#

Remove effect-free statements and provably empty control flow.

Returns:

fpass (tvm_tirx.ir.transform.Pass) – The result pass

Examples

import tvm_tirx as tvm
from tvm_tirx.script import ir as I, tirx as T
from tvm_tirx.tirx import transform as tr

@I.ir_module
class Before:
    @T.function(private=True)
    def main(A: T.Tensor((1,), T.int32)):
        T.evaluate(1)
        A[0] = 1

@I.ir_module
class Expected:
    @T.function(private=True)
    def main(A: T.Tensor((1,), T.int32)):
        A[0] = 1

def run_pass():
    return tr.RemoveNoOp()(Before)

tvm.ir.assert_structural_equal(run_pass(), Expected)