tvm_tirx.tirx.transform.SkipAssert

Contents

tvm_tirx.tirx.transform.SkipAssert#

tvm_tirx.tirx.transform.SkipAssert()#

Replace assertion statements with no-ops.

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), n: T.int32):
        assert n > 0, ("RuntimeError", ["positive extent required"])
        A[0] = 1

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

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

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