Johnson9009 opened a new pull request #8634:
URL: https://github.com/apache/tvm/pull/8634
Current default "opt_level" of Sequential is 2, this value will lead to bug
when sequential nested.
The below test case can't pass, through the opt_level of pass SimplifyExpr
is 0, but the opt_level of wrapper sequential is 2, so the pass SimplifyExpr
will not be run.
```python
def test_nested_sequential_with_scoping():
def before():
x = relay.var("x", shape=(1, 16, 16, 16), dtype="float32")
w = relay.var("w", shape=(32, 16, 3, 3), dtype="float32")
y = relay.nn.conv2d(x, w, padding=(1, 1))
y = relay.reshape(y, newshape=(1, 16, -1))
y = relay.reshape(y, newshape=(4, 8, -1, 16))
y = relay.reverse_reshape(y, newshape=(32, 0, -1))
return tvm.IRModule.from_expr(y)
def expected():
x = relay.var("x", shape=(1, 16, 16, 16), dtype="float32")
w = relay.var("w", shape=(32, 16, 3, 3), dtype="float32")
y = relay.nn.conv2d(x, w, padding=(1, 1))
y = relay.reshape(y, newshape=(32, 16, 16))
return tvm.IRModule.from_expr(y)
z = before()
passes = [
tvm.transform.Sequential([relay.transform.SimplifyExpr()]),
]
with tvm.transform.PassContext(opt_level=1):
zz = tvm.transform.Sequential(passes)(z)
expected = relay.transform.InferType()(expected())
assert tvm.ir.structural_equal(zz, expected)
```
Actually from the comments of class Sequential, it seems we think the
default value of this opt_level should be 0, but the code is not changed.
https://github.com/apache/tvm/blob/main/python/tvm/ir/transform.py#L189-L193
@tqchen @zhiics
--
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]