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/08/05 18:52:45 UTC
[GitHub] [incubator-tvm] anijain2305 opened a new pull request #6217: [TFLite, QNN] Slice op
anijain2305 opened a new pull request #6217:
URL: https://github.com/apache/incubator-tvm/pull/6217
TFLite quantized slice op has same input and output qnn params. Just adding a check and a test case.
@d-smirnov Please take a look at this PR if it can help simplify - https://github.com/apache/incubator-tvm/pull/6018
@u99127
----------------------------------------------------------------
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
[GitHub] [incubator-tvm] tqchen closed pull request #6217: [TFLite, QNN] Slice op
Posted by GitBox <gi...@apache.org>.
tqchen closed pull request #6217:
URL: https://github.com/apache/incubator-tvm/pull/6217
----------------------------------------------------------------
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
[GitHub] [incubator-tvm] u99127 commented on pull request #6217: [TFLite, QNN] Slice op
Posted by GitBox <gi...@apache.org>.
u99127 commented on pull request #6217:
URL: https://github.com/apache/incubator-tvm/pull/6217#issuecomment-678486170
>
>
> TFLite quantized slice op has same input and output qnn params. Just adding a check and a test case.
>
> @d-smirnov Please take a look at this PR if it can help simplify - #6018 My goal was to keep the changes minimal here.
>
> @u99127
LGTM modulo @siju-samuel 's comments.
----------------------------------------------------------------
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
[GitHub] [incubator-tvm] siju-samuel commented on a change in pull request #6217: [TFLite, QNN] Slice op
Posted by GitBox <gi...@apache.org>.
siju-samuel commented on a change in pull request #6217:
URL: https://github.com/apache/incubator-tvm/pull/6217#discussion_r466170310
##########
File path: tests/python/frontend/tflite/test_forward.py
##########
@@ -352,21 +352,47 @@ def test_forward_split():
# slice
# -----
-def _test_slice(data, begin, size):
+def _test_slice(data, begin, size, quantized=False):
""" One iteration of SLICE """
- with tf.Graph().as_default():
- in_data = array_ops.placeholder(shape=data.shape, dtype=data.dtype)
- out = array_ops.slice(in_data, begin, size)
- compare_tflite_with_tvm(data, 'Placeholder:0', [in_data], [out])
+ if quantized:
+ with tf.Graph().as_default():
+ data_array = np.random.uniform(0, 255, data.shape).astype('uint8')
+ in_data = array_ops.placeholder(shape=data.shape, dtype=data.dtype, name="in_data")
+ # Ensure that min/max for inputs and outputs are same
+ min_value = -100
+ max_value = 100
+ inq_data = tf.quantization.fake_quant_with_min_max_args(in_data, min=min_value,
+ max=max_value, name='inq_data')
+ out = array_ops.slice(inq_data, begin, size)
+ out = tf.quantization.fake_quant_with_min_max_args(out, min=min_value,
+ max=max_value, name="out")
+
+ # Set the input quantization range
+ input_range = {'in_data': (min_value, max_value)} if quantized else None
+
+ # Compare
+ compare_tflite_with_tvm(data_array, 'in_data', [in_data], [out], quantized=quantized, input_range=input_range)
+
+ else:
+ with tf.Graph().as_default():
+ in_data = array_ops.placeholder(shape=data.shape, dtype=data.dtype, name="in_data")
+ out = array_ops.slice(in_data, begin, size)
+ input_range = {'in_data': (-100, 100)} if quantized else None
+ compare_tflite_with_tvm([data], ['in_data:0'], [in_data], [out],
Review comment:
This 2 common statements, put outside if-else block.
##########
File path: python/tvm/relay/frontend/tflite.py
##########
@@ -2088,6 +2088,14 @@ def convert_slice(self, op):
input_tensor = input_tensors[0]
in_expr = self.get_expr(input_tensor.tensor_idx)
+ # If the tensors are quantized, ensure that input/output qnn params are same.
+ if input_tensor.qnn_params:
+ output_tensors = self.get_output_tensors(op)
+ assert len(output_tensors) == 1, "There should be only 1 output tensor"
+ output_tensor = output_tensors[0]
+ assert self.has_same_qnn_params(input_tensor, output_tensor), \
+ "TFLite reshape requires input and output scale and zero points to be equal"
Review comment:
Tflite reshape -> Tflite slice
----------------------------------------------------------------
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
[GitHub] [incubator-tvm] anijain2305 commented on pull request #6217: [TFLite, QNN] Slice op
Posted by GitBox <gi...@apache.org>.
anijain2305 commented on pull request #6217:
URL: https://github.com/apache/incubator-tvm/pull/6217#issuecomment-669522678
@siju-samuel Please review.
----------------------------------------------------------------
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