You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by ma...@apache.org on 2022/06/24 10:04:37 UTC
[tvm] branch main updated: [fix] quantize op consistent with python description (#11872)
This is an automated email from the ASF dual-hosted git repository.
masahi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new b99d93afec [fix] quantize op consistent with python description (#11872)
b99d93afec is described below
commit b99d93afec217f1dabc8b25e2e95251e50079ae8
Author: sisleyli <43...@users.noreply.github.com>
AuthorDate: Fri Jun 24 18:04:32 2022 +0800
[fix] quantize op consistent with python description (#11872)
* move round op before `add expanded_output_zero_point`
* consistent with python description `(round(input_tensor/output_scale) + output_zero_point`
---
src/relay/qnn/op/quantize.cc | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/relay/qnn/op/quantize.cc b/src/relay/qnn/op/quantize.cc
index da33aaac81..1a16705932 100644
--- a/src/relay/qnn/op/quantize.cc
+++ b/src/relay/qnn/op/quantize.cc
@@ -142,11 +142,10 @@ Expr QuantizeLower(const Expr& input_tensor, const Expr& output_scale,
const int32_t min_val = GetQmin(out_dtype);
const int32_t max_val = GetQmax(out_dtype);
- auto scale_data = Divide(input_tensor, expanded_output_scale);
+ auto scale_data = Round(Divide(input_tensor, expanded_output_scale));
auto add_zero_point = Add(scale_data, Cast(expanded_output_zero_point, DataType::Float(32)));
auto clamped_output = Clip(add_zero_point, min_val, max_val);
- auto rounded_clamped_output = Round(clamped_output);
- return Cast(rounded_clamped_output, out_dtype);
+ return Cast(clamped_output, out_dtype);
}
Expr QuantizeQnnCanonicalize(const Attrs& attrs, const Array<Expr>& new_args,