Aharrypotter commented on code in PR #19538:
URL: https://github.com/apache/tvm/pull/19538#discussion_r3265072092


##########
python/tvm/relax/frontend/tflite/tflite_frontend.py:
##########
@@ -2637,27 +2545,27 @@ def convert_fully_connected(self, op):
                         dtype=bias_tensor_type_str,
                         source_name=bias_tensor.tensor.Name(),
                     )
+                if bias_tensor.qnn_params:
+                    bias_expr = self.dequantize(bias_expr, bias_tensor)
+                elif input_tensor.qnn_params and bias_tensor_type in (
+                    TensorType.INT32,
+                    TensorType.INT64,
+                ):
+                    bias_scale_val = (
+                        
get_scalar_from_constant(input_tensor.qnn_params["scale"])
+                        * 
get_scalar_from_constant(weight_tensor.qnn_params["scale"])
+                    )
+                    bias_expr = relax.op.dequantize(
+                        bias_expr,
+                        scale=relax.const(bias_scale_val, "float32"),
+                        zero_point=relax.const(0, "int32"),
+                        axis=0,
+                    )

Review Comment:
   Done — replaced get_scalar_from_constant with relax.op.multiply so the bias 
scale works for both per-tensor and per-channel weight quantization. The 
multiply result is passed directly to relax.op.dequantize as a Relax expression.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to