Hello all,
I have found myself having to do some AST manipulation (via a custom ir_pass
).
Reading the Writing a Customized Pass Tutorial, I know that I can manipulate the AST via the tvm.ir_pass.IRTransform(input_stmt, preorder_func, postorder_func,[list_of_AST_nodes])
construct.
Replacing an AST node is quite easy but I have no clue how to remove a node
define postorder_func(stmt):
irb = tvm.ir_builder.create()
if some_condition:
#replace the AST node
irb.emit(tvm.stmt.SomeStatementType(...))
return irb.get()
else:
#remove the AST node
irb.emit(...)
return irb.get() #not returning a value doesn't help eiter
All the tvm.stmt
types that I can find are “non-NOP” and therefore generate an AST node.
I tried tvm.stmt.Eval(0)
but I obviously get a 0 printed in my code (which I can deal with but I’d rather have it removed).
Is there something completely obvious that I am missing?
Thanks