[DT] Graduate data-tiling fusion from experimental flag to binding option. (#21745)
The data-tiling path starting from DispatchCreation phase is very close
to be useful. Thus, we can start guarding the path under the binding
option. It is shown in two CI jobs:
- IREE tests:
https://github.com/iree-org/iree/actions/runs/17116883103/job/48549667004?pr=21441
- Integration tests:
https://github.com/iree-org/iree/actions/runs/17116883094/job/48549979850?pr=21441
The only failure is a lowering strategy selection in x86 config, which
will be gone with proper fix for the workaround.
The revision also introduces `dataTiling` option to
`iree-dispatch-creation-pipeline` that exposes the control to
`iree-opt`, because the binding options are not available in `iree-opt`
scope.
Note: the PR is not linked directly, because it can be force-push. Thus,
only the links to CI jobs are provided in the commit description.
---------
Signed-off-by: hanhanW <hanhan0912@gmail.com>
diff --git a/compiler/src/iree/compiler/DispatchCreation/Passes.cpp b/compiler/src/iree/compiler/DispatchCreation/Passes.cpp
index 6e9f5a4..e6329e2 100644
--- a/compiler/src/iree/compiler/DispatchCreation/Passes.cpp
+++ b/compiler/src/iree/compiler/DispatchCreation/Passes.cpp
@@ -61,16 +61,6 @@
"Enables horizontal fusion of contractions with one common operand"),
llvm::cl::init(false));
-static llvm::cl::opt<bool> clEnableDataTiling(
- "iree-dispatch-creation-experimental-data-tiling",
- llvm::cl::desc("Enable data-tiling at flow level, i.e., it sets encodings "
- "in dispatch regions, hoist them out of region, and enables "
- "fusion for the set_encodings. This is still an "
- "experimental path. The current main data tiling path is "
- "iree-opt-data-tiling, which is on by default. To use this "
- "path, --iree-opt-data-tiling=false must be set as wells"),
- llvm::cl::init(false));
-
static llvm::cl::opt<DispatchCreation::EncodingOptions> clSetEncodingStrategy(
"iree-dispatch-creation-set-encoding-strategy",
llvm::cl::desc("Set the encoding strategy for operations."),
@@ -263,7 +253,7 @@
// Experimental data tiling path. The intent of this path is to set encodings
// after fusion decisions have already been made, so encodings can be
// separated from compiler fusion decisions.
- if (clEnableDataTiling) {
+ if (options.dataTiling) {
FunctionLikeNest(passManager)
// Run canonicalizer first to make propagation easier.
.addPass([&]() {
@@ -397,10 +387,17 @@
"Enable aggressive fusion for dispatch creation pipeline"),
llvm::cl::init(false),
};
+ Option<bool> dataTiling{
+ *this,
+ "data-tiling",
+ llvm::cl::desc("Enable data-tiling for dispatch creation pipeline"),
+ llvm::cl::init(false),
+ };
std::unique_ptr<TransformOptions> toTransformOptions() const {
auto options = std::make_unique<TransformOptions>();
options->options.enableAggressiveFusion = aggressiveFusion;
+ options->options.dataTiling = dataTiling;
return options;
}
};
diff --git a/compiler/src/iree/compiler/DispatchCreation/test/set_encoding_pipeline.mlir b/compiler/src/iree/compiler/DispatchCreation/test/set_encoding_pipeline.mlir
index 0ae8687..90932f4 100644
--- a/compiler/src/iree/compiler/DispatchCreation/test/set_encoding_pipeline.mlir
+++ b/compiler/src/iree/compiler/DispatchCreation/test/set_encoding_pipeline.mlir
@@ -1,5 +1,4 @@
-// RUN: iree-opt --split-input-file --pass-pipeline="builtin.module(iree-dispatch-creation-pipeline)" \
-// RUN: --iree-dispatch-creation-experimental-data-tiling %s | FileCheck %s
+// RUN: iree-opt --split-input-file --pass-pipeline="builtin.module(iree-dispatch-creation-pipeline{data-tiling})" %s | FileCheck %s
// Tests to make sure that the set encoding pass work as in the dispatch
// creation pipeline. For example, we expect dimension collapsing to happen
diff --git a/compiler/src/iree/compiler/Pipelines/Options.cpp b/compiler/src/iree/compiler/Pipelines/Options.cpp
index 95bb11f..25ee33b 100644
--- a/compiler/src/iree/compiler/Pipelines/Options.cpp
+++ b/compiler/src/iree/compiler/Pipelines/Options.cpp
@@ -312,6 +312,9 @@
"since all backends dont support it yet"));
binder.opt<bool>("iree-dispatch-creation-fuse-multi-use", enableFuseMultiUse,
llvm::cl::desc("Fuse operations with multiple uses."));
+ binder.opt<bool>("iree-dispatch-creation-data-tiling", dataTiling,
+ llvm::cl::desc("Enables data tiling path."),
+ llvm::cl::cat(category));
}
} // namespace mlir::iree_compiler
diff --git a/compiler/src/iree/compiler/Pipelines/Options.h b/compiler/src/iree/compiler/Pipelines/Options.h
index 0a58655..338f18a 100644
--- a/compiler/src/iree/compiler/Pipelines/Options.h
+++ b/compiler/src/iree/compiler/Pipelines/Options.h
@@ -121,7 +121,9 @@
// Enables transposing all concatenations to the outer most dimension.
bool outerDimConcat = false;
- // Enables data tiling.
+ // Enables data tiling in global optimization phase. There are two data-tiling
+ // flags during the transition state. The other has to be off if this one is
+ // enabled. Any feature built on top of this path will be deprecated.
bool dataTiling = true;
// Enables const-expr hoisting into globals.
@@ -220,6 +222,12 @@
bool enableAggressiveFusion = false;
bool enableFuseMultiUse = true;
+ // Enables data tiling in dispatch creation phase. There are two data-tiling
+ // flags during the transition state. The other has to be off if this one is
+ // enabled. The main difference is that this path enables the fusion for
+ // data-tiled ops.
+ bool dataTiling = false;
+
void bindOptions(OptionsBinder &binder);
using FromFlags = OptionsFromFlags<DispatchCreationOptions>;
};
diff --git a/tests/e2e/linalg/BUILD.bazel b/tests/e2e/linalg/BUILD.bazel
index c3a2608..84dc0bb 100644
--- a/tests/e2e/linalg/BUILD.bazel
+++ b/tests/e2e/linalg/BUILD.bazel
@@ -57,7 +57,7 @@
name = "check_llvm-cpu_dt_fusion_local-task",
srcs = ["narrow_n_matmuls.mlir"],
compiler_flags = [
- "--iree-dispatch-creation-experimental-data-tiling",
+ "--iree-dispatch-creation-data-tiling",
"--iree-llvmcpu-target-cpu=generic",
"--iree-opt-data-tiling=false",
],
diff --git a/tests/e2e/linalg/CMakeLists.txt b/tests/e2e/linalg/CMakeLists.txt
index a543ed9..41465c7 100644
--- a/tests/e2e/linalg/CMakeLists.txt
+++ b/tests/e2e/linalg/CMakeLists.txt
@@ -44,7 +44,7 @@
DRIVER
"local-task"
COMPILER_FLAGS
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-llvmcpu-target-cpu=generic"
"--iree-opt-data-tiling=false"
LABELS
diff --git a/tests/e2e/matmul/CMakeLists.txt b/tests/e2e/matmul/CMakeLists.txt
index 683fe17..a5e1cda 100644
--- a/tests/e2e/matmul/CMakeLists.txt
+++ b/tests/e2e/matmul/CMakeLists.txt
@@ -1424,7 +1424,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
"--iree-llvmgpu-test-combine-layout-transformation=true"
LABELS
@@ -1454,7 +1454,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
"--iree-llvmgpu-test-combine-layout-transformation=true"
LABELS
@@ -1484,7 +1484,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
"--iree-llvmgpu-test-combine-layout-transformation=true"
LABELS
@@ -1515,7 +1515,7 @@
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
"--iree-hip-enable-ukernels=multi_mma"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
"--iree-llvmgpu-test-combine-layout-transformation=true"
LABELS
@@ -1545,7 +1545,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
"--iree-llvmgpu-test-combine-layout-transformation=true"
LABELS
@@ -1575,7 +1575,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
"--iree-llvmgpu-test-combine-layout-transformation=true"
LABELS
@@ -1605,7 +1605,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
"--iree-llvmgpu-test-combine-layout-transformation=true"
LABELS
@@ -1635,7 +1635,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-input-demote-f64-to-f32=false"
"--iree-hip-encoding-layout-resolver=data-tiling"
"--iree-llvmgpu-test-combine-layout-transformation=true"
@@ -1666,7 +1666,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling=true"
+ "--iree-dispatch-creation-data-tiling"
"--iree-dispatch-creation-set-encoding-strategy=padding"
"--iree-hip-encoding-layout-resolver=pad"
LABELS
@@ -1696,7 +1696,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling=true"
+ "--iree-dispatch-creation-data-tiling"
"--iree-dispatch-creation-set-encoding-strategy=padding"
"--iree-hip-encoding-layout-resolver=pad"
LABELS
@@ -1827,7 +1827,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
RUNNER_ARGS
"--require_exact_results=false"
@@ -1859,7 +1859,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
LABELS
"noasan"
@@ -2050,7 +2050,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
RUNNER_ARGS
"--require_exact_results=false"
@@ -2082,7 +2082,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
RUNNER_ARGS
"--require_exact_results=false"
@@ -2114,7 +2114,7 @@
COMPILER_FLAGS
${IREE_HIP_TEST_COMPILER_FLAGS}
"--iree-opt-data-tiling=false"
- "--iree-dispatch-creation-experimental-data-tiling"
+ "--iree-dispatch-creation-data-tiling"
"--iree-hip-encoding-layout-resolver=data-tiling"
LABELS
"noasan"