Skip to content

Commit

Permalink
Simplify tests/e2e/stablehlo_ops. (iree-org#17843)
Browse files Browse the repository at this point in the history
Forking this from iree-org#17766 to just
look at a single directory.

* Moved Metal and ROCm tests from being exclusively defined in CMake to
being defined (but then no-op'd) in Bazel
* Taught the test function to insert
`--iree-rocm-target-chip=${IREE_HIP_TEST_TARGET_CHIP}` (not happy that
this is required though)
* Merged test srcs down to a single `ALL_SRCS` glob for test suites that
work across all configurations
* Enabled previously disabled tests
  * Fixes iree-org#9583
* Fixes iree-org#12415 (maybe, might have
to disable those tests on Android/Vulkan again)
  • Loading branch information
ScottTodd authored Jul 10, 2024
1 parent e000353 commit 78c0051
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 298 deletions.
15 changes: 10 additions & 5 deletions build_tools/bazel/iree_check_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
load("//build_tools/bazel:iree_bytecode_module.bzl", "iree_bytecode_module")
load("//build_tools/bazel:native_binary.bzl", "native_test")

ALL_TARGET_BACKENDS_AND_DRIVERS = [
DEFAULT_TARGET_BACKENDS_AND_DRIVERS = [
("vmvx", "local-task"),
("vulkan-spirv", "vulkan"),
("llvm-cpu", "local-task"),
Expand Down Expand Up @@ -122,6 +122,14 @@ def iree_check_single_backend_test_suite(
test suite.
"""

# Metal backend/driver not supported by Bazel build.
if target_backend == "metal-spirv" or driver == "metal":
return

# ROCm/HIP backend/driver not supported by Bazel build.
if target_backend == "rocm" or driver == "hip":
return

# We haven't implemented this so far because we have been using target_cpu_features so far only
# for aarch64 targets, for which we use the CMake build. To future people implementing this:
# target_cpu_features should be a list, and here it should be joined into a comma-separated
Expand Down Expand Up @@ -162,7 +170,7 @@ def iree_check_single_backend_test_suite(
def iree_check_test_suite(
name,
srcs,
target_backends_and_drivers = ALL_TARGET_BACKENDS_AND_DRIVERS,
target_backends_and_drivers = DEFAULT_TARGET_BACKENDS_AND_DRIVERS,
compiler_flags = [],
input_type = None,
runner_args = [],
Expand Down Expand Up @@ -207,9 +215,6 @@ def iree_check_test_suite(
# could just create a test suite. The latter seems simpler and more readable.
tests = []
for backend, driver in target_backends_and_drivers:
# CUDA backend/driver not supported by Bazel build.
if backend == "cuda" or driver == "cuda":
continue
suite_name = "_".join([name, backend, driver])
iree_check_single_backend_test_suite(
name = suite_name,
Expand Down
14 changes: 12 additions & 2 deletions build_tools/cmake/iree_check_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ function(iree_check_test)
${ARGN}
)

# Normalize some variables before using them.
string(TOUPPER ${_RULE_TARGET_BACKEND} _UPPERCASE_TARGET_BACKEND)
string(REPLACE "-" "_" _NORMALIZED_TARGET_BACKEND ${_UPPERCASE_TARGET_BACKEND})

# ---------------------------------------------------------------------------
# Bytecode module builds require
# 1. the compiler, either in the same build or provided in IREE_HOST_BIN_DIR
Expand Down Expand Up @@ -92,15 +96,17 @@ function(iree_check_test)
# backends are enabled. We could query the tools in the binary directory for
# support dynamically if optionality would be useful.
if(NOT IREE_HOST_BIN_DIR)
string(TOUPPER ${_RULE_TARGET_BACKEND} _UPPERCASE_TARGET_BACKEND)
string(REPLACE "-" "_" _NORMALIZED_TARGET_BACKEND ${_UPPERCASE_TARGET_BACKEND})
# TODO(scotttodd): allow plugins to provide external backends here
if(NOT DEFINED IREE_TARGET_BACKEND_${_NORMALIZED_TARGET_BACKEND})
message(SEND_ERROR "Unknown backend '${_RULE_TARGET_BACKEND}'. Check IREE_TARGET_BACKEND_* options.")
endif()
if(NOT IREE_TARGET_BACKEND_${_NORMALIZED_TARGET_BACKEND})
set(_BYTECODE_MODULE_BUILD_ENABLED FALSE)
endif()
# rocm/hip require a target chip to be specified at compile time that matches the runtime device
if(_NORMALIZED_TARGET_BACKEND STREQUAL "ROCM" AND NOT IREE_HIP_TEST_TARGET_CHIP)
set(_BYTECODE_MODULE_BUILD_ENABLED FALSE)
endif()
endif()
# ---------------------------------------------------------------------------

Expand Down Expand Up @@ -159,6 +165,9 @@ function(iree_check_test)
if(_RULE_TARGET_CPU_FEATURES)
list(APPEND _BASE_COMPILER_FLAGS "--iree-llvmcpu-target-cpu-features=${_RULE_TARGET_CPU_FEATURES}")
endif()
if(_NORMALIZED_TARGET_BACKEND STREQUAL "ROCM")
list(APPEND _BASE_COMPILER_FLAGS "--iree-rocm-target-chip=${IREE_HIP_TEST_TARGET_CHIP}")
endif()

if(_BYTECODE_MODULE_BUILD_ENABLED)
iree_bytecode_module(
Expand Down Expand Up @@ -437,6 +446,7 @@ function(iree_check_test_suite)
endif()

if(NOT DEFINED _RULE_TARGET_BACKENDS AND NOT DEFINED _RULE_DRIVERS)
# Default backends/drivers.
set(_RULE_TARGET_BACKENDS "vmvx" "vulkan-spirv" "llvm-cpu")
set(_RULE_DRIVERS "local-task" "vulkan" "local-task")
endif()
Expand Down
Loading

0 comments on commit 78c0051

Please sign in to comment.