Aharrypotter commented on code in PR #19538:
URL: https://github.com/apache/tvm/pull/19538#discussion_r3265065001
##########
python/tvm/relax/frontend/tflite/tflite_frontend.py:
##########
@@ -4461,34 +4375,26 @@ def convert_transpose_conv(self, op):
dtype=bias_tensor_type_str,
source_name=bias_tensor.tensor.Name(),
)
- channel_axis = 3
- out = relax.op.nn.bias_add(out, bias_expr, axis=channel_axis)
+ 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(weights_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]