Skip to content

Commit ea34e6e

Browse files
authored
[TOPHUB] use keys as a keyword for searching of existing statistics (#13874)
* [TOPHUB] use keys as a keyword for searching of existing statistics In case of ARM we might not specify -device and in this case llvm will be used while even in this case we can determin proper filename with stat since keys have architecture defined. The same situatin must with with x86 * Add test on target not having arm_cpu device * minor fix, add comment * Fix pylint * Fix comment
1 parent 37e1a68 commit ea34e6e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

python/tvm/autotvm/tophub.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,20 @@ def context(target, extra_files=None):
106106
if isinstance(tgt, str):
107107
tgt = Target(tgt)
108108

109+
# The TOPHUB file names rely on Target's device or kind. Both these types of
110+
# information exist in Target.keys, but rules of filling this filed is not explicitly
111+
# defined, we are afraid to rely only on Target.keys. At the same time Target.device
112+
# is filled only if device was pointed explicitly in target string, that is not mandatory
113+
# and in some cases we need to get information about device from Target.keys
114+
# In priority order we verify:
115+
# 1) Target.device
116+
# 2) Target.keys
117+
# 3) Target.kind
109118
possible_names = []
110119
device = tgt.attrs.get("device", "")
111120
if device != "":
112121
possible_names.append(_alias(device))
122+
possible_names.extend(tgt.keys)
113123
possible_names.append(tgt.kind.name)
114124

115125
all_packages = list(PACKAGE_VERSION.keys())

tests/python/unittest/test_autotvm_dispatch_context.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
to the parameters of workload"""
2020

2121
from tvm import autotvm
22+
import tvm
2223

2324

2425
@autotvm.template("testing/dispatch_fallback")
@@ -31,5 +32,20 @@ def test_fallback():
3132
simple_template(2, 3)
3233

3334

35+
def test_tophub_kinds_match():
36+
def verify_arm_cpu(target):
37+
best_by_targetkey = autotvm.tophub.context(target).best_by_targetkey
38+
assert len(best_by_targetkey)
39+
found_arm_cpu = False
40+
for a, _ in best_by_targetkey:
41+
if "arm_cpu" in a:
42+
found_arm_cpu = True
43+
break
44+
assert found_arm_cpu
45+
46+
verify_arm_cpu("llvm -device=arm_cpu -mtriple=aarch64-linux-gnu -mattr=+neon,+v8.2a,+dotprod")
47+
verify_arm_cpu("llvm -model=snapdragon835 -mtriple=arm64-linux-android -mattr=+neon")
48+
49+
3450
if __name__ == "__main__":
3551
test_fallback()

0 commit comments

Comments
 (0)