From baeee37030fee8a134fb9bb9cf84280ade7d6753 Mon Sep 17 00:00:00 2001 From: Eric Lunderberg Date: Tue, 7 Jun 2022 14:40:18 -0500 Subject: [PATCH] [Hexagon][CI] Re-enable Hexagon tests in CI These were enabled in https://github.com/apache/tvm/pull/11294, then erroneously disabled in https://github.com/apache/tvm/pull/11313. This applies the same fix as in https://github.com/apache/tvm/pull/11294, checking the `ANDROID_SERIAL_NUMBER` to determine if Hexagon tests can execute at runtime, but using the refactored `pytest.skipif` messages introduced in https://github.com/apache/tvm/pull/11313. --- python/tvm/contrib/hexagon/pytest_plugin.py | 38 ++++++++++++++++----- python/tvm/testing/utils.py | 8 ++--- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/python/tvm/contrib/hexagon/pytest_plugin.py b/python/tvm/contrib/hexagon/pytest_plugin.py index 2c62a0a0b569..5c1ce7b4eda0 100644 --- a/python/tvm/contrib/hexagon/pytest_plugin.py +++ b/python/tvm/contrib/hexagon/pytest_plugin.py @@ -26,6 +26,7 @@ import pytest import tvm +import tvm.testing import tvm.rpc.tracker from tvm.contrib.hexagon.build import HexagonLauncher, HexagonLauncherRPC from tvm.contrib.hexagon.session import Session @@ -53,15 +54,36 @@ def _compose(args, decs): return decs -def requires_hexagon_toolchain(*args): - _requires_hexagon_toolchain = [ - pytest.mark.skipif( - os.environ.get(HEXAGON_TOOLCHAIN) is None, - reason=f"Missing environment variable {HEXAGON_TOOLCHAIN}.", - ), - ] +def _compile_time_check(): + """Return True if compile-time support for Hexagon is present, otherwise + error string. - return _compose(args, _requires_hexagon_toolchain) + Designed for use as a the ``compile_time_check`` argument to + `tvm.testing.Feature`. + """ + if _cmake_flag_enabled("USE_LLVM") and tvm.target.codegen.llvm_version_major() < 7: + return "Hexagon requires LLVM 7 or later" + + if "HEXAGON_TOOLCHAIN" not in os.environ: + return f"Missing environment variable {HEXAGON_TOOLCHAIN}." + + return True + + +def _run_time_check(): + """Return True if run-time support for Hexagon is present, otherwise + error string. + + Designed for use as a the ``run_time_check`` argument to + `tvm.testing.Feature`. + """ + if ANDROID_SERIAL_NUMBER not in os.environ: + return f"Missing environment variable {ANDROID_SERIAL_NUMBER}." + + return True + + +requires_hexagon_toolchain = tvm.testing.requires_hexagon(support_required="compile-only") @tvm.testing.fixture diff --git a/python/tvm/testing/utils.py b/python/tvm/testing/utils.py index 939786c9294f..1b37dd8b7f00 100644 --- a/python/tvm/testing/utils.py +++ b/python/tvm/testing/utils.py @@ -88,6 +88,7 @@ def test_something(): import tvm._ffi from tvm.contrib import nvcc, cudnn +from tvm.contrib.hexagon import pytest_plugin as hexagon from tvm.error import TVMError @@ -937,11 +938,8 @@ def _any_gpu_exists(): "Hexagon", cmake_flag="USE_HEXAGON", target_kind_enabled="hexagon", - compile_time_check=lambda: ( - (_cmake_flag_enabled("USE_LLVM") and tvm.target.codegen.llvm_version_major() >= 7) - or "Hexagon requires LLVM 7 or later" - ), - target_kind_hardware="hexagon", + compile_time_check=hexagon._compile_time_check, + run_time_check=hexagon._run_time_check, parent_features="llvm", )