giuseros commented on a change in pull request #5980:
URL: https://github.com/apache/incubator-tvm/pull/5980#discussion_r454545412



##########
File path: src/relay/qnn/op/requantize.cc
##########
@@ -153,9 +153,19 @@ Expr RequantizeLower(const Expr& input_tensor, const Expr& 
input_scale,
         static_cast<double>(input_scale_float) / 
static_cast<double>(output_scale_float);
     // Skip if input and output scales are same.
     if (!IsEqualScalar(input_scale, output_scale)) {
-      scaled_int32_t =
-          FixedPointMultiply(scaled_int32_t, double_multiplier, input_shape, 
param->rounding);
+      int32_t fixed_point_multiplier, shift;
+      std::tie(fixed_point_multiplier, shift) = 
GetFixedPointMultiplierShift(double_multiplier);
+
+      const bool is_upward_rounding = (param->rounding == "UPWARD");
+
+      // When using upward rounding (i.e., x.5 rounded to x+1), leverage
+      // the fixed_point_muliply intrinsic
+      scaled_int32_t = (is_upward_rounding ? relay::FixedPointMultiply(
+                                                 scaled_int32_t, 
fixed_point_multiplier, shift)
+                                           : 
FixedPointMultiply(scaled_int32_t, double_multiplier,

Review comment:
       I changed the utility function with `FixedPointMultiplyToNearest` and 
removed the conditions on the rounding. 




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to