[GitHub] [incubator-tvm] u99127 commented on a change in pull request #5452: [Frontend][TFLite] L2_POOL_2D operator

2020-04-27 Thread GitBox


u99127 commented on a change in pull request #5452:
URL: https://github.com/apache/incubator-tvm/pull/5452#discussion_r416146885



##
File path: python/tvm/relay/frontend/tflite.py
##
@@ -1770,6 +1775,12 @@ def convert_pool2d(self, op, pool_type):
 assert self.has_same_qnn_params(input_tensor, output_tensor), \
 "qnn.op.max_pool2d requires input and output qnn 
params to be same"
 out = _op.nn.max_pool2d(in_expr, **params)
+elif pool_type == "l2":
+# l2_pool_2d is equivalent to 
square_root(avg_pool(square(in_data)))

Review comment:
   Putting in the check has the following benefits:
   
   1. Better user experience as the rest of the stack doesn't get basically 
undefined behaviour because of random input.. 
   2. A signal to us as a community in the form of a bug report that this is 
appearing. 
   
   Ramana





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:
us...@infra.apache.org




[GitHub] [incubator-tvm] u99127 commented on a change in pull request #5452: [Frontend][TFLite] L2_POOL_2D operator

2020-04-27 Thread GitBox


u99127 commented on a change in pull request #5452:
URL: https://github.com/apache/incubator-tvm/pull/5452#discussion_r416144493



##
File path: tests/python/frontend/tflite/test_forward.py
##
@@ -487,6 +487,31 @@ def test_forward_pooling():
   strides=[2, 1])
 
 
+def _test_l2_pool2d(input_shape, ksize, strides, padding, data_format, 
fused_func_name=None):
+x = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) 
- 1
+
+with tf.Graph().as_default():
+in_data = tf.placeholder(
+dtype=tf.float32, name="input", shape=input_shape)
+out = tf.sqrt(tf.nn.avg_pool(
+tf.square(in_data), ksize=ksize, strides=strides,
+padding=padding, data_format=data_format))
+out = with_fused_activation_function(out, fused_func_name)
+
+compare_tflite_with_tvm(x, 'input', [in_data], [out])

Review comment:
   Thanks , possibly worth a belts and braces check to ensure we catch this 
in the frontend to ensure we think through qnn support rather than getting an 
unknown failure.





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:
us...@infra.apache.org




[GitHub] [incubator-tvm] u99127 commented on a change in pull request #5452: [Frontend][TFLite] L2_POOL_2D operator

2020-04-27 Thread GitBox


u99127 commented on a change in pull request #5452:
URL: https://github.com/apache/incubator-tvm/pull/5452#discussion_r415699554



##
File path: tests/python/frontend/tflite/test_forward.py
##
@@ -487,6 +487,31 @@ def test_forward_pooling():
   strides=[2, 1])
 
 
+def _test_l2_pool2d(input_shape, ksize, strides, padding, data_format, 
fused_func_name=None):
+x = np.arange(np.prod(input_shape), dtype=np.float32).reshape(input_shape) 
- 1
+
+with tf.Graph().as_default():
+in_data = tf.placeholder(
+dtype=tf.float32, name="input", shape=input_shape)
+out = tf.sqrt(tf.nn.avg_pool(
+tf.square(in_data), ksize=ksize, strides=strides,
+padding=padding, data_format=data_format))
+out = with_fused_activation_function(out, fused_func_name)
+
+compare_tflite_with_tvm(x, 'input', [in_data], [out])

Review comment:
   Very quick drive-by review : 
   Don't we need a qnn test here ? I haven't managed to read up L2_POOL_2D in 
the tflite documentation yet. 





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:
us...@infra.apache.org