Skip to content

Commit 5fac8b2

Browse files
Alex-Wenggclaude
andcommitted
[GlobalOpt] Move softmax matcher out of iree-dialects (#24466)
Relocate the StructuredOpMatcher infrastructure and makeSoftmaxMatcher from llvm-external-projects/iree-dialects into the GlobalOptimization directory, which holds the only production user (RaiseSpecialOps). The code is moved verbatim (NFC); RaiseSpecialOps is repointed to the local header and the build deps are switched to the MLIR libraries the matcher needs. The now-unused matchers (reduction/matmul/convolution/pad) come along verbatim and can be trimmed in a follow-up once a build is available to validate. Progress toward retiring the iree-dialects dependency. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 82f1670 commit 5fac8b2

5 files changed

Lines changed: 3063 additions & 5 deletions

File tree

compiler/src/iree/compiler/GlobalOptimization/BUILD.bazel

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ iree_compiler_cc_library(
7171
"RaiseSpecialOps.cpp",
7272
"RemoveZeroExtentTensors.cpp",
7373
"SimplifyPackUnpack.cpp",
74+
"TransformMatchers.cpp",
7475
"Utils.cpp",
7576
"WarnOnUninitializedValues.cpp",
7677
],
7778
hdrs = [
7879
"Passes.h",
80+
"TransformMatchers.h",
7981
"Utils.h",
8082
],
8183
deps = [
@@ -103,29 +105,33 @@ iree_compiler_cc_library(
103105
"//compiler/src/iree/compiler/Modules/IO/Parameters/Transforms",
104106
"//compiler/src/iree/compiler/Pipelines:Options",
105107
"//compiler/src/iree/compiler/Utils",
106-
"//llvm-external-projects/iree-dialects:IREEDialectsTransforms",
107-
"//llvm-external-projects/iree-dialects:IREELinalgTransformDialect",
108108
"@llvm-project//llvm:Support",
109109
"@llvm-project//mlir:AffineDialect",
110+
"@llvm-project//mlir:Analysis",
110111
"@llvm-project//mlir:ArithDialect",
111112
"@llvm-project//mlir:ArithUtils",
112113
"@llvm-project//mlir:ControlFlowDialect",
113114
"@llvm-project//mlir:DialectUtils",
115+
"@llvm-project//mlir:FuncDialect",
114116
"@llvm-project//mlir:FunctionInterfaces",
115117
"@llvm-project//mlir:IR",
116118
"@llvm-project//mlir:LinalgDialect",
119+
"@llvm-project//mlir:LinalgInterfaces",
117120
"@llvm-project//mlir:LinalgTransforms",
118121
"@llvm-project//mlir:LinalgUtils",
119122
"@llvm-project//mlir:MathDialect",
120123
"@llvm-project//mlir:MemRefDialect",
121124
"@llvm-project//mlir:MemRefTransforms",
122125
"@llvm-project//mlir:Pass",
126+
"@llvm-project//mlir:Rewrite",
123127
"@llvm-project//mlir:SCFDialect",
124128
"@llvm-project//mlir:SCFTransforms",
125129
"@llvm-project//mlir:Support",
126130
"@llvm-project//mlir:TensorDialect",
127131
"@llvm-project//mlir:TensorTransforms",
128132
"@llvm-project//mlir:TensorUtils",
133+
"@llvm-project//mlir:TransformDialect",
134+
"@llvm-project//mlir:TransformDialectInterfaces",
129135
"@llvm-project//mlir:TransformUtils",
130136
"@llvm-project//mlir:Transforms",
131137
],

compiler/src/iree/compiler/GlobalOptimization/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ iree_cc_library(
3838
GlobalOptimization
3939
HDRS
4040
"Passes.h"
41+
"TransformMatchers.h"
4142
"Utils.h"
4243
SRCS
4344
"CleanupNumericNarrowing.cpp"
@@ -62,33 +63,38 @@ iree_cc_library(
6263
"RaiseSpecialOps.cpp"
6364
"RemoveZeroExtentTensors.cpp"
6465
"SimplifyPackUnpack.cpp"
66+
"TransformMatchers.cpp"
6567
"Utils.cpp"
6668
"WarnOnUninitializedValues.cpp"
6769
DEPS
6870
::PassHeaders
6971
::PassesIncGen
70-
IREEDialectsTransforms
71-
IREELinalgTransformDialect
7272
LLVMSupport
7373
MLIRAffineDialect
74+
MLIRAnalysis
7475
MLIRArithDialect
7576
MLIRArithUtils
7677
MLIRControlFlowDialect
78+
MLIRFuncDialect
7779
MLIRFunctionInterfaces
7880
MLIRIR
7981
MLIRLinalgDialect
82+
MLIRLinalgInterfacesIncGenLib
8083
MLIRLinalgTransforms
8184
MLIRLinalgUtils
8285
MLIRMathDialect
8386
MLIRMemRefDialect
8487
MLIRMemRefTransforms
8588
MLIRPass
89+
MLIRRewrite
8690
MLIRSCFDialect
8791
MLIRSCFTransforms
8892
MLIRSupport
8993
MLIRTensorDialect
9094
MLIRTensorTransforms
9195
MLIRTensorUtils
96+
MLIRTransformDialect
97+
MLIRTransformDialectInterfaces
9298
MLIRTransformUtils
9399
MLIRTransforms
94100
iree::compiler::Codegen::Common

compiler/src/iree/compiler/GlobalOptimization/RaiseSpecialOps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66

7-
#include "iree-dialects/Transforms/TransformMatchers.h"
87
#include "iree/compiler/Dialect/Flow/Transforms/RegionOpUtils.h"
98
#include "iree/compiler/Dialect/LinalgExt/IR/LinalgExtDialect.h"
109
#include "iree/compiler/Dialect/LinalgExt/IR/LinalgExtInterfaces.h"
1110
#include "iree/compiler/Dialect/LinalgExt/IR/LinalgExtOps.h"
1211
#include "iree/compiler/Dialect/LinalgExt/Utils/Utils.h"
1312
#include "iree/compiler/GlobalOptimization/Passes.h"
13+
#include "iree/compiler/GlobalOptimization/TransformMatchers.h"
1414
#include "iree/compiler/GlobalOptimization/Utils.h"
1515
#include "llvm/ADT/STLExtras.h"
1616
#include "llvm/Support/Casting.h"

0 commit comments

Comments
 (0)