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 2022/06/01 21:53:56 UTC

[GitHub] [tvm] Lunderberg commented on a diff in pull request #11417: [Hexagon] Implement avg_pool2d slice op

Lunderberg commented on code in PR #11417:
URL: https://github.com/apache/tvm/pull/11417#discussion_r887332670


##########
tests/python/contrib/test_hexagon/infrastructure.py:
##########
@@ -228,3 +227,18 @@ def compute(n, ho, wo, ko, hi, wi, ki):
         )
 
     return output_shape, compute
+
+
+# Transpose and reshape numpy array according to the specified layout
+def transform_numpy(arr_np, layout):
+    if layout == "nhwc":
+        return arr_np
+    elif layout == "nhwc-8h2w32c2w":
+        N, H, W, C = arr_np.shape
+        return arr_np.reshape([N, H // 8, 8, W // 4, 2, 2, C // 32, 32]).transpose(0, 1, 3, 6, 2, 4, 7, 5)
+    elif layout == "n11c-1024c":
+        N, H, W, C = arr_np.shape
+        assert (H == 1 and W == 1), "The size of H and W must be 1!"
+        return arr_np.reshape([N, C//1024, 1024]).transpose(0, 1, 2)

Review Comment:
   No problem.  I'm thinking that at some point, it might be useful to have a utility that converts a numpy array according to a `IndexMap`, to avoid needing to write the same transformation in numpy semantics.



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org