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/08 18:05:15 UTC

[GitHub] [tvm] Icemist commented on a diff in pull request #13578: [FQ2I] Support converting `dense` -> `add` to `qnn.dense` -> `add` -> `requantize`

Icemist commented on code in PR #13578:
URL: https://github.com/apache/tvm/pull/13578#discussion_r1043642842


##########
python/tvm/relay/frontend/onnx.py:
##########
@@ -1406,7 +1406,10 @@ def _impl_v1(cls, inputs, attr, params):
             inputs[0] *= _expr.const(alpha, dtype=dtype)
         out = _op.nn.dense(inputs[0], inputs[1], units=channels)
         if len(inputs) == 3:
-            out = out + _expr.const(beta, dtype=dtype) * inputs[2]
+            if beta != 1.0:

Review Comment:
   Since we do not use 1.0 in the calculations, I would suggest not to use it at all. something like:
   ```
   beta = attr.get("beta")
   ```
   ...
   ```
   if beta is None:
   	out = out + inputs[2]
   else:
   	out = out + _expr.const(float(beta), dtype=dtype) * inputs[2]
   ```
   
   
   or 
   ```
   input_2 = inputs[2] 
   if beta is not None:  # can be written in 1 line ternary operator
   	input_2 = input_2 * expr.const(float(beta), dtype=dtype)
   out = out + input_2
   ```
   



-- 
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