Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TOPHUB] use keys as a keyword for searching of existing statistics #13874

Merged
merged 5 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions python/tvm/autotvm/tophub.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,20 @@ def context(target, extra_files=None):
if isinstance(tgt, str):
tgt = Target(tgt)

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

all_packages = list(PACKAGE_VERSION.keys())
Expand Down
16 changes: 16 additions & 0 deletions tests/python/unittest/test_autotvm_dispatch_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
to the parameters of workload"""

from tvm import autotvm
import tvm


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


def test_tophub_kinds_match():
def verify_arm_cpu(target):
best_by_targetkey = autotvm.tophub.context(target).best_by_targetkey
assert len(best_by_targetkey)
found_arm_cpu = False
for a, _ in best_by_targetkey:
if "arm_cpu" in a:
found_arm_cpu = True
break
assert found_arm_cpu

verify_arm_cpu("llvm -device=arm_cpu -mtriple=aarch64-linux-gnu -mattr=+neon,+v8.2a,+dotprod")
verify_arm_cpu("llvm -model=snapdragon835 -mtriple=arm64-linux-android -mattr=+neon")


if __name__ == "__main__":
test_fallback()