Fixing HAL executable benchmarks after workgroup count ops. (#10098)
A new `hal.executable.calculate_workgroups` pseudo-op allows for
pre-translation workgroup counts to be queried from the host-side program
which will then be resolved during conversion to the full HAL dialect
using whatever calculation functions the translation produced.
diff --git a/tests/compiler_driver/BUILD b/tests/compiler_driver/BUILD
index c4d5332..273bb11 100644
--- a/tests/compiler_driver/BUILD
+++ b/tests/compiler_driver/BUILD
@@ -19,6 +19,7 @@
name = "lit",
srcs = enforce_glob(
[
+ "executable_benchmarks.mlir",
"hal_executable.mlir",
"smoketest.mlir",
"streams.mlir",
diff --git a/tests/compiler_driver/CMakeLists.txt b/tests/compiler_driver/CMakeLists.txt
index 04fa8d9..2e20917 100644
--- a/tests/compiler_driver/CMakeLists.txt
+++ b/tests/compiler_driver/CMakeLists.txt
@@ -14,6 +14,7 @@
NAME
lit
SRCS
+ "executable_benchmarks.mlir"
"hal_executable.mlir"
"smoketest.mlir"
"streams.mlir"
diff --git a/tests/compiler_driver/executable_benchmarks.mlir b/tests/compiler_driver/executable_benchmarks.mlir
new file mode 100644
index 0000000..2cf1b9c
--- /dev/null
+++ b/tests/compiler_driver/executable_benchmarks.mlir
@@ -0,0 +1,21 @@
+// RUN: iree-compile %s -o ignored.mlir \
+// RUN: --iree-hal-target-backends=vmvx \
+// RUN: --iree-hal-dump-executable-benchmarks-to=- | \
+// RUN: iree-compile - --output-format=vm-asm | \
+// RUN: FileCheck %s
+
+// Tests that it's possible to round-trip executable benchmarks produced by the
+// compiler back to the compiler individually. This test relies on us piping
+// stdout and that there's only a single executable (otherwise we'd need to look
+// at files and that's harder cross-platform).
+
+func.func @abs(%input : tensor<f32>) -> (tensor<f32>) {
+ %result = math.abs %input : tensor<f32>
+ return %result : tensor<f32>
+}
+
+// We expect one executable and one exported function with the reflection attrs.
+// CHECK: vm.rodata private @abs_dispatch_0_vmvx_bytecode_fb
+// CHECK: vm.func private @abs_dispatch_0_vmvx_bytecode_fb_abs_dispatch_0{{.+}}(%arg0: i32)
+// CHECK-SAME: iree.reflection = {iree.benchmark = "dispatch"}
+// CHECK: vm.call @hal.command_buffer.dispatch