mehrdadh commented on code in PR #12294:
URL: https://github.com/apache/tvm/pull/12294#discussion_r940482420


##########
tests/python/contrib/test_hexagon/test_conv_hvx_intrinsics.py:
##########
@@ -0,0 +1,168 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import numpy as np
+import tvm.testing
+import tvm.topi.testing
+
+from numpy.random import default_rng
+from tvm.tir.function import TensorIntrin
+
+from tests.python.contrib.test_hexagon.conv_uint8 import get_const_tuple, 
run_conv_te
+from tests.python.contrib.test_hexagon.conv_uint8_hvx_intrin import 
get_conv_uint8_hvx_intrin
+from tests.python.contrib.test_hexagon.quantization_utils import 
quantize_array, quantize_uint8
+
+
+class TestConvHVX:
+    def create_inputs(input_shape, filter_shape, mem_scope):
+
+        w_size, _, _, _ = filter_shape
+        input_padding = w_size // 2
+
+        rng = default_rng()
+        a = rng.integers(1, 255, input_shape, dtype="uint8")
+        w = rng.integers(1, 8, filter_shape, dtype="uint8")
+
+        a_q, a_min, a_max = quantize_array(a.reshape(a.size), a.size)
+        w_q, b_min, b_max = quantize_array(w.reshape(w.size), w.size)
+
+        a_q = np.array(a_q, dtype="uint8").reshape(input_shape)
+        w_q = np.array(w_q, dtype="uint8").reshape(filter_shape)
+
+        a_offset = quantize_uint8(0.0, a_min, a_max)
+        w_offset = quantize_uint8(0.0, b_min, b_max)
+
+        a_f = np.array(a_q, dtype="uint8").reshape(get_const_tuple(a.shape))
+        w_f = np.array(w_q, dtype="uint8").reshape(get_const_tuple(w.shape))
+        expected_output = tvm.topi.testing.conv2d_nhwc_python(a_f, w_f, 1, 
input_padding).astype(
+            "int32"
+        )
+
+        return a_q, w_q, a_offset, w_offset, expected_output, mem_scope
+
+    a, w, a_offset, w_offset, expected_output, mem_scope = 
tvm.testing.parameters(
+        (create_inputs((2, 128, 128, 3), (3, 3, 3, 2), "local")),
+        (create_inputs((2, 128, 128, 3), (3, 3, 3, 2), "global")),
+        (create_inputs((2, 128, 128, 3), (3, 3, 3, 2), "global.vtcm")),
+        (create_inputs((1, 128, 128, 3), (7, 7, 3, 1), "local")),
+        (create_inputs((1, 128, 128, 3), (5, 5, 3, 1), "local")),
+        (create_inputs((1, 128, 128, 3), (3, 3, 3, 1), "local")),
+        (create_inputs((4, 128, 128, 1), (3, 3, 1, 4), "local")),
+        (create_inputs((2, 32, 32, 32), (7, 7, 32, 2), "local")),
+        (create_inputs((2, 34, 34, 29), (5, 5, 29, 2), "local")),
+        (create_inputs((1, 512, 512, 1), (9, 9, 1, 1), "local")),
+    )
+
+    @tvm.testing.requires_hexagon
+    def test_vrmpy_conv(
+        self, hexagon_session, a, w, a_offset, w_offset, expected_output, 
mem_scope
+    ):
+
+        # TODO even sized kernels and stride are currently not working.

Review Comment:
   please change this to: `TODO(your github handler): ...` format



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to