You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "Lunderberg (via GitHub)" <gi...@apache.org> on 2023/10/02 20:42:14 UTC

Re: [PR] [TFLite][Frontend] Fix test failures caused by div-by-zero [tvm]

Lunderberg commented on code in PR #15844:
URL: https://github.com/apache/tvm/pull/15844#discussion_r1343143062


##########
tests/python/frontend/tflite/test_forward.py:
##########
@@ -2480,6 +2481,16 @@ def __test_elemwise(in_data):
                 inq0_min, inq0_max = (out_min, out_max)
                 inq1_min, inq1_max = (out_min, out_max)
 
+            if exclude_zero_point:
+                if inq1_max == inq1_min:
+                    raise ZeroDivisionError("Input range is 0.")
+
+                # only compute for rhs.
+                quant_scale = 255 / (inq1_max - inq1_min)
+                zero_point = int(round(-inq1_min * quant_scale))
+                data[1][data[1] == zero_point] += 1
+                data[1][data[1] == 0] += 1

Review Comment:
   Is this second adjustment required?  Looking at the two next two each other, its seems like the first (when `data[1] == zero_point`) would only be required when these are pre-quantized values, and the second (when `data[1] == 0`) would only be required when these are post-quantization values, and that only one of those can be true at a time.



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org