anijain2305 commented on a change in pull request #4282: Add test for the
qnn_add operator
URL: https://github.com/apache/incubator-tvm/pull/4282#discussion_r344304495
##########
File path: tests/python/frontend/tflite/test_forward.py
##########
@@ -545,34 +561,55 @@ def test_forward_concatenation():
# Element-wise
# ---
-def _test_elemwise(math_op, data, fused_activation_function=None):
+def _test_elemwise(math_op, data, fused_activation_function=None,
quantized=False):
""" One iteration of elemwise """
assert len(data) == 2
# Test with two tensors
with tf.Graph().as_default():
- in_data = [array_ops.placeholder(shape=data[0].shape,
dtype=data[0].dtype, name='in_0'),
- array_ops.placeholder(shape=data[1].shape,
dtype=data[1].dtype, name='in_1')]
- out = math_op(in_data[0], in_data[1])
- out = with_fused_activation_function(out, fused_activation_function)
- compare_tflite_with_tvm(data, ['in_0:0', 'in_1:0'], in_data, [out])
+ in_data = [array_ops.placeholder(shape=data[0].shape, dtype='float32',
name='in_0'),
+ array_ops.placeholder(shape=data[1].shape, dtype='float32',
name='in_1')]
+
+ if quantized:
+ # fake_quant will keep the tensors in float32 until the conversion
in the session
+ inq_data =
[tf.quantization.fake_quant_with_min_max_args(in_data[0], min=-100, max=100,
name="inq_0"),
+
tf.quantization.fake_quant_with_min_max_args(in_data[1], min=-100, max=100,
name="inq_1")]
+ out = math_op(inq_data[0], inq_data[1])
+ out = with_fused_activation_function(out,
fused_activation_function)
+ out = tf.quantization.fake_quant_with_min_max_args(out, min=-200,
max=200, name="out")
+ compare_tflite_with_tvm(data, ['inq_0:0', 'inq_1:0'], inq_data,
[out], quantized=True)
+
Review comment:
Minor - Remove the blank line
----------------------------------------------------------------
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]
With regards,
Apache Git Services