tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-tvm] siju-samuel commented on a change in pull request #5452: [Frontend][TFLite] L2_POOL_2D operator
Date Mon, 27 Apr 2020 17:11:25 GMT

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



##########
File path: tests/python/frontend/tflite/test_forward.py
##########
@@ -561,6 +561,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])
+
+
+def test_l2_pool2d():

Review comment:
       add `test_l2_pool2d` to __main__

##########
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:
       Add a protection check to throw error if you receive quantized inputs.




----------------------------------------------------------------
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



Mime
View raw message