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 2020/02/03 21:27:21 UTC
[GitHub] [incubator-tvm] anijain2305 commented on a change in pull request
#4789: [Frontend][TFLite] Dynamically calculate input_stats of any
fake_quant range
anijain2305 commented on a change in pull request #4789: [Frontend][TFLite] Dynamically calculate input_stats of any fake_quant range
URL: https://github.com/apache/incubator-tvm/pull/4789#discussion_r374350076
##########
File path: tests/python/frontend/tflite/test_forward.py
##########
@@ -143,11 +144,13 @@ def compare_tflite_with_tvm(in_data, in_name, input_tensors,
converter.inference_type = tf.lite.constants.QUANTIZED_UINT8
input_arrays = converter.get_input_arrays()
input_stats = {}
- # hardcode the mean_values and std_dev_values (m,s) to be the same
- # if all inputs are in (float_min; float_max) == (-100, 100)
+ # calculate the mean and quantization scale for every input tensor,
+ # with respect to its fp32 input range, defined in fake_quant.
# s = 255/(fmax-fmin); m = -fmin*s (the zero point)
for i in input_arrays:
- input_stats[i] = (128., 1.275)
+ quant_scale = 255 / (input_range[i][1] - input_range[i][0])
Review comment:
Minor
* Lets add a check to ensure that denominator is not zero.
* Typically QNN_scale = FP32_range/QNN_range, so suggest to double-check if TFLite accepts inverse scale.
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services