janetsc commented on code in PR #13349:
URL: https://github.com/apache/tvm/pull/13349#discussion_r1022119475
##########
tests/python/contrib/test_hexagon/test_cache_read_write.py:
##########
@@ -222,5 +223,28 @@ def _visit(stmt):
)
+def _raises_exception(f):
+ try:
+ f()
+ except Exception:
+ return True
+ return False
+
+
[email protected]("vtcm_capacity,limited", [(65536, False), (8192,
True)])
+def test_vtcm_limit(vtcm_capacity, limited):
+ """Test lowering with vtcm mem scope"""
+ mod = tvm.IRModule.from_expr(scale_by_two.with_attr("global_symbol",
"main"))
+ sch = tir.Schedule(mod, debug_mask="all")
+ block_c = sch.get_block("C")
+ (flat,) = sch.get_loops(block_c)
+ outer, _, _, _ = sch.split(flat, factors=[8, 4, 2, 128])
+ cache_block = sch.cache_read(block_c, 0, storage_scope="global.vtcm")
+ sch.compute_at(cache_block, outer)
+
+ with tvm.transform.PassContext(config={"tir.vtcm_capacity":
vtcm_capacity}):
Review Comment:
It would be interesting in the future if we could pass this capacity down to
the device API for two reasons - to verify that it is possible, and to attempt
to allocate only that size from QURT in HexagonVtcmPool
##########
tests/python/unittest/test_tir_analysis_calculate_allocated_memory.py:
##########
@@ -0,0 +1,65 @@
+# 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 pytest
+
+import tvm
+from tvm import tir
+from tvm.script import tir as T
+
+
+# fmt: off
[email protected]_func
+def matmul_some_scope(a: T.handle, b: T.handle, c: T.handle) -> None:
+ A = T.match_buffer(a, [128, 128], scope="global")
+ A_ = T.alloc_buffer([128, 128], dtype="float32", scope="global.texture")
+ B = T.match_buffer(b, [128, 128], scope="global")
+ B_ = T.alloc_buffer([128, 128], dtype="float32", scope="global.texture")
+ C = T.match_buffer(c, [128, 128], scope="global")
+ C_ = T.alloc_buffer([128, 128], dtype="float32", scope="global")
+
+ for i, j in T.grid(128, 128):
+ with T.block("A_.texture"):
+ A_[i, j] = A[i, j]
+ for i, j in T.grid(128, 128):
+ with T.block("B_.texture"):
+ B_[i, j] = B[i, j]
+
+ for i, j, k in T.grid(128, 128, 128):
+ with T.block("update"):
+ vi, vj, vk = T.axis.remap("SSR", [i, j, k])
+ with T.init():
+ C_[vi, vj] = 0.0
+ C_[vi, vj] = C_[vi, vj] + A_[vi, vk] * B_[vj, vk]
+
+ for i, j in T.grid(128, 128):
+ with T.block("C"):
+ C[i, j] = C_[i, j]
+# fmt: on
+
+
[email protected](
+ "scope,size", [("global", 131072), ("global.texture", 131072*2),
("global.texture-nhwc", 0)]
+)
+def test_allocates(scope, size):
Review Comment:
Can you add a test specifically to make sure the calculated VTCM size
matches what we expect? (To make sure it picks up "global.vtcm", as the
LowerVtcmAlloc pass alters those nodes.)
--
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]