You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/12/26 14:58:18 UTC

[GitHub] [tvm] ibsidorenko opened a new pull request, #13660: [QNN] Change in Pass Context for lookup table calculation.

ibsidorenko opened a new pull request, #13660:
URL: https://github.com/apache/tvm/pull/13660

   **Motivation:**
   It is possible to disable specific passes through the "disabled_pass" parameter in the Pass Context. These "disabled" passes can be optional for one target and mandatory for another one.
   Since lookup table for some QNN operations (tanh, round and etc.) is calculated on the host and some of disabled passes can be required for the host, no need to disable these passes. This constant calculation/ evaluation is orthogonal to the compilation process for specific target.
   
   **What was changed:**
   This commit creates its own compilation Pass Context for lookup table
   calculation and evaluation (for elemwise QNN ops: tanh, sqrt ...).


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] masahi commented on a diff in pull request #13660: [QNN] Change in Pass Context for lookup table calculation

Posted by GitBox <gi...@apache.org>.
masahi commented on code in PR #13660:
URL: https://github.com/apache/tvm/pull/13660#discussion_r1057489938


##########
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:
   Do you mean, without `disabled_pass=[]`, the original `disabled_pass` list in the current context will be ignored during const folding?



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] tvm-bot commented on pull request #13660: [QNN] Change in Pass Context for lookup table calculation.

Posted by GitBox <gi...@apache.org>.
tvm-bot commented on PR #13660:
URL: https://github.com/apache/tvm/pull/13660#issuecomment-1365233227

   <!---bot-comment-->
   
   Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
   
   <!--bot-comment-ccs-start-->
    * No users to tag found in teams: `qnn` <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
   
   <sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] masahi merged pull request #13660: [QNN] Change in Pass Context for lookup table calculation

Posted by GitBox <gi...@apache.org>.
masahi merged PR #13660:
URL: https://github.com/apache/tvm/pull/13660


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] ibsidorenko commented on pull request #13660: [QNN] Change in Pass Context for lookup table calculation

Posted by GitBox <gi...@apache.org>.
ibsidorenko commented on PR #13660:
URL: https://github.com/apache/tvm/pull/13660#issuecomment-1365249471

   @tvm-bot rerun


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] ibsidorenko commented on pull request #13660: [QNN] Change in Pass Context for lookup table calculation

Posted by GitBox <gi...@apache.org>.
ibsidorenko commented on PR #13660:
URL: https://github.com/apache/tvm/pull/13660#issuecomment-1365658521

   cc @masahi @AndrewZhaoLuo 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] ibsidorenko commented on a diff in pull request #13660: [QNN] Change in Pass Context for lookup table calculation

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] masahi commented on a diff in pull request #13660: [QNN] Change in Pass Context for lookup table calculation

Posted by GitBox <gi...@apache.org>.
masahi commented on code in PR #13660:
URL: https://github.com/apache/tvm/pull/13660#discussion_r1057915918


##########
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 see, you do want to enable QNN legalization (which is disabled in the original ctx) here.



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org