Skip to content

Commit 4a55820

Browse files
[Hexagon] Add default vtcm capacity for targets (#15414)
* [Hexagon] Add default vtcm capacity for targets This patch adds VTCM default capacity values for different target architectures so that it can be queried at compile time from targets * Update test case
1 parent d9c2b9c commit 4a55820

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

python/tvm/target/target.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,14 +699,25 @@ def get_arch_version(cpu_ver):
699699
msg = "{} is not a valid Hexagon version\nvalid versions include {}"
700700
raise ValueError(msg.format(cpu_ver, valid_hex)) from None
701701

702+
def get_vtcm_capacity(cpu_ver):
703+
one_mb = 2**20
704+
default_vtcm_sizes = {
705+
"v65": one_mb // 4,
706+
"v66": one_mb // 4,
707+
"v68": 4 * one_mb,
708+
"v69": 8 * one_mb,
709+
"v73": 8 * one_mb,
710+
}
711+
return default_vtcm_sizes.get(cpu_ver, 0)
712+
702713
# Target configuration:
703714
arch_version = get_arch_version(cpu_ver)
704715
config = {
705716
"hvx": 128,
706717
"llvm_options": None,
707718
"use_qfloat": arch_version >= 68,
708719
"use_ieee_fp": False,
709-
"vtcm_capacity": 0,
720+
"vtcm_capacity": get_vtcm_capacity(cpu_ver),
710721
}
711722
config.update(kwargs)
712723

tests/python/contrib/test_hexagon/test_vtcm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def _raises_exception(f):
7979

8080
with tvm.transform.PassContext(config={"tir.vtcm_capacity": vtcm_capacity}):
8181
assert (
82-
_raises_exception(lambda: tvm.build(sch.mod, target=get_hexagon_target("v68")))
82+
_raises_exception(
83+
lambda: tvm.build(sch.mod, target=get_hexagon_target("v68", vtcm_capacity=0))
84+
)
8385
== limited
8486
), "Case 3 - context. VTCM memory allocation limiter does not work correctly "
8587

0 commit comments

Comments
 (0)