wrongtest opened a new pull request #10410: URL: https://github.com/apache/tvm/pull/10410
Hi, the pr try to fix exception `Check failed: (can_dispatch(n)) is false: NodeFunctor calls un-registered function on type relay.alter_op_layout.LayoutAlternatedExprNode`. For the pass using `TempExpr` and `ForwardRewrite`, there is code path which will leak unrealized `TempExpr` if sub-function body is also transformed to `TempExpr`. Since the user-defined realizer will not necessary do the full recursion, https://github.com/apache/tvm/blob/main/src/relay/transforms/forward_rewrite.cc#L46. we can explicitly realize the func op body during rewriting. The script to reproduce is as below: ```python import tvm from tvm.ir.module import IRModule from tvm import relay x = relay.var("x", shape=[1, 256, 130, 130], dtype="float32") w = relay.var("w", shape=[64, 256, 1, 1], dtype="float32") b = relay.var("w", shape=[64], dtype="float32") conv = relay.nn.conv2d(x, w, padding=[0,0,0,0], channels=64, kernel_size=[1,1]) exp = relay.expand_dims(b, axis=1, num_newaxis=2) add = conv + exp f = relay.Function([x, w, b], add) xx = relay.var("xx", shape=[1, 256, 130, 130], dtype="float32") ww = relay.var("ww", shape=[64, 256, 1, 1], dtype="float32") bb = relay.var("bb", shape=[64], dtype="float32") yy = f(xx, ww, bb) yy2 = relay.image.resize2d(yy, size=[520, 520], roi=[0.,0.,0.,0.], rounding_method="") ff = relay.Function([xx, ww, bb], yy2) mod = IRModule.from_expr(ff) mod = relay.transform.InferType()(mod) with tvm.ir.transform.PassContext(opt_level=3): relay.build(mod, target="llvm") ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
