manupa-arm commented on a change in pull request #9164:
URL: https://github.com/apache/tvm/pull/9164#discussion_r720008049
##########
File path: tests/python/relay/test_pass_fold_constant.py
##########
@@ -298,6 +298,31 @@ def before():
assert tvm.ir.structural_equal(run_infer_type(before_mod["main"]),
after_mod["main"])
+def test_fold_qnn_quantize():
+ t = relay.TensorType([1, 2, 3], "int8")
+
+ def before():
+ data = tvm.nd.array(np.array([1.0, 2.0, 3.0], dtype="float32"))
+ const_fp = relay.const(data, dtype="float32")
+ const_i8 = relay.qnn.op.quantize(const_fp,
output_scale=relay.const(0.5), output_zero_point=relay.const(0))
+ x = relay.var("x", t)
+ add = relay.op.add(x, const_i8)
+ func = relay.Function([x], add)
+ return func
+
+ def expected():
+ data = tvm.nd.array(np.array([2, 4, 6], dtype="int8"))
+ const_i8 = relay.const(data, dtype="int8")
+ x = relay.var("x", t)
+ add = relay.op.add(x, const_i8)
+ func = relay.Function([x], add)
+ return func
+
+ zz = run_opt_pass(before(), transform.FoldConstant())
Review comment:
How is it different from running Legalize followed by FoldConstant ?
--
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]