Skip to content

Commit d490620

Browse files
authored
[Hexagon][CI] Re-enable Hexagon tests in CI (#11613)
* [Hexagon][CI] Re-enable Hexagon tests in CI These were enabled in #11294, then erroneously disabled in #11313. This applies the same fix as in #11294, checking the `ANDROID_SERIAL_NUMBER` to determine if Hexagon tests can execute at runtime, but using the refactored `pytest.skipif` messages introduced in #11313. * Fixed circular dependency, but feels somewhat ugly
1 parent 774ee96 commit d490620

File tree

3 files changed

+66
-14
lines changed

3 files changed

+66
-14
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
"""Hexagon environment checks for CI usage
19+
20+
These may be required by either tvm.testing or
21+
tvm.contrib.hexagon.pytest_plugin, and are separated here to avoid a
22+
circular dependency.
23+
"""
24+
25+
import os
26+
27+
import tvm
28+
29+
ANDROID_SERIAL_NUMBER = "ANDROID_SERIAL_NUMBER"
30+
HEXAGON_TOOLCHAIN = "HEXAGON_TOOLCHAIN"
31+
32+
33+
def _compile_time_check():
34+
"""Return True if compile-time support for Hexagon is present, otherwise
35+
error string.
36+
37+
Designed for use as a the ``compile_time_check`` argument to
38+
`tvm.testing.Feature`.
39+
"""
40+
if (
41+
tvm.testing.utils._cmake_flag_enabled("USE_LLVM")
42+
and tvm.target.codegen.llvm_version_major() < 7
43+
):
44+
return "Hexagon requires LLVM 7 or later"
45+
46+
if "HEXAGON_TOOLCHAIN" not in os.environ:
47+
return f"Missing environment variable {HEXAGON_TOOLCHAIN}."
48+
49+
return True
50+
51+
52+
def _run_time_check():
53+
"""Return True if run-time support for Hexagon is present, otherwise
54+
error string.
55+
56+
Designed for use as a the ``run_time_check`` argument to
57+
`tvm.testing.Feature`.
58+
"""
59+
if ANDROID_SERIAL_NUMBER not in os.environ:
60+
return f"Missing environment variable {ANDROID_SERIAL_NUMBER}."
61+
62+
return True

python/tvm/contrib/hexagon/pytest_plugin.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,7 @@ def _compose(args, decs):
5353
return decs
5454

5555

56-
def requires_hexagon_toolchain(*args):
57-
_requires_hexagon_toolchain = [
58-
pytest.mark.skipif(
59-
os.environ.get(HEXAGON_TOOLCHAIN) is None,
60-
reason=f"Missing environment variable {HEXAGON_TOOLCHAIN}.",
61-
),
62-
]
63-
64-
return _compose(args, _requires_hexagon_toolchain)
56+
requires_hexagon_toolchain = tvm.testing.requires_hexagon(support_required="compile-only")
6557

6658

6759
@tvm.testing.fixture

python/tvm/testing/utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def test_something():
8888
import tvm._ffi
8989

9090
from tvm.contrib import nvcc, cudnn
91+
import tvm.contrib.hexagon._ci_env_check as hexagon
9192
from tvm.error import TVMError
9293

9394

@@ -937,11 +938,8 @@ def _any_gpu_exists():
937938
"Hexagon",
938939
cmake_flag="USE_HEXAGON",
939940
target_kind_enabled="hexagon",
940-
compile_time_check=lambda: (
941-
(_cmake_flag_enabled("USE_LLVM") and tvm.target.codegen.llvm_version_major() >= 7)
942-
or "Hexagon requires LLVM 7 or later"
943-
),
944-
target_kind_hardware="hexagon",
941+
compile_time_check=hexagon._compile_time_check,
942+
run_time_check=hexagon._run_time_check,
945943
parent_features="llvm",
946944
)
947945

0 commit comments

Comments
 (0)