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/09/10 02:55:09 UTC

[GitHub] [tvm] wrongtest-intellif commented on a diff in pull request #12750: [TIR, Schedule] Add schedule primitive PadEinsum

wrongtest-intellif commented on code in PR #12750:
URL: https://github.com/apache/tvm/pull/12750#discussion_r967571170


##########
tests/python/unittest/test_tir_schedule_pad_einsum.py:
##########
@@ -0,0 +1,123 @@
+# 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.
+# pylint: disable=missing-function-docstring,missing-module-docstring
+import sys
+
+import pytest
+import tvm
+import tvm.testing
+from tvm import tir, te
+from tvm.script import tir as T
+from tvm.tir.schedule.schedule import ScheduleError
+from tvm.tir.schedule.testing import verify_trace_roundtrip
+from tvm.meta_schedule.testing import te_workload
+
+# pylint: disable=no-member,invalid-name,unused-variable,unexpected-keyword-arg
+
+
+@T.prim_func
+def matmul_before(
+    A: T.Buffer[(128, 127), "float32"],
+    B: T.Buffer[(127, 127), "float32"],
+    C: T.Buffer[(128, 127), "float32"],
+) -> None:
+    A_shared = T.alloc_buffer((128, 127), "float32", scope="shared")
+    B_shared = T.alloc_buffer((127, 127), "float32", scope="shared")
+    C_shared = T.alloc_buffer((128, 127), "float32", scope="shared")
+    for i0, i1 in T.grid(128, 127):
+        with T.block("A"):
+            i, j = T.axis.remap("SS", [i0, i1])
+            A_shared[i, j] = A[i, j]
+    for i0, i1 in T.grid(127, 127):
+        with T.block("B"):
+            i, j = T.axis.remap("SS", [i0, i1])
+            B_shared[i, j] = B[i, j]
+    for i0, i1, i2 in T.grid(128, 127, 127):
+        with T.block("C_shared"):
+            i, j, k = T.axis.remap("SSR", [i0, i1, i2])
+            with T.init():
+                C_shared[i, j] = T.float32(0)
+            C_shared[i, j] = C_shared[i, j] + A_shared[i, k] * B_shared[k, j]
+    for i0, i1 in T.grid(128, 127):
+        with T.block("C"):
+            i, j = T.axis.remap("SS", [i0, i1])
+            C[i, j] = C_shared[i, j]
+
+
+@T.prim_func
+def matmul_expected(

Review Comment:
   Compare to https://github.com/apache/tvm/pull/12720 cc @Lunderberg 
   Could I understand that it equals with a bundle of operations in certain workload pattern? Like
   ```python
   for buffer in [A_shared, B_shared, C_shared]:
        s.transpose_layout(buffer, (127, 127) -> (128, 128), pad_value=0)
   for block in [A, B, C_shared]:
        for axis in s.get_loops(block)
            s.fuse(*s.split(axis, [1, 128]))
   s.annotate(C_shared, "en_some_predicate_versus_overcomputation_selection", 1)
           
   ```



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