ibsidorenko commented on code in PR #13660:
URL: https://github.com/apache/tvm/pull/13660#discussion_r1057708382
##########
python/tvm/relay/qnn/op/canonicalizations.py:
##########
@@ -23,10 +23,25 @@
def run_const_expr(expr: "relay.Expr") -> np.ndarray:
- """Evaluate a const expression, receiving result as np array."""
- mod = tvm.IRModule.from_expr(expr)
- vm_exe = relay.create_executor("vm", mod=mod)
- return vm_exe.evaluate()().asnumpy()
+ """Evaluate a const expression, receiving result as np array.
+
+ If a number of passes are disabled in the current Pass Context, then there
is no need to disable
+ these passes for const expression evaluation as well. That's why we use
empty list
+ "disabled_pass=[]", all other arguments are inherited from the current
Pass Context.
Review Comment:
I put here `disabled_pass=[]` to ignore the original `disabled_pass` list
from the current context. Otherwise VM inherits non-empty `disabled_pass` list
and fails.
Note, we call this code only for several qnn ops: tanh, sqrt, erf, exp +
some other ops. It does not affect global constant folding.
For clarification, here is my example to illustrate this issue:
I am trying to compile subgraph with `qnn.tanh` operation for Hexagon target
**without** QNN canonicalization but **with** QNN legalization (this is
acceptable for Hexagon). For `qnn.tanh` we compose lookup table by means of
Virtual Machine and compute it on the host. For most of users/developers host
is x86 cpu. But for x86 QNN canonicalization is mandatory pass, otherwise it
fails.
Looks like the simplest way to fix this issue is to create new Pass Context
and ignore the original `disabled_pass` list for lookup table calculation and
constant evaluation. Other arguments (opt_level, instruments, config ...) I
inherit from the current context.
P.S. Corresponding unit test will be added in the next PR.
--
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]