Skip to content

Commit

Permalink
[Codegen] Add ability to specify transform dialect libraries (#14788)
Browse files Browse the repository at this point in the history
This adds the ability to specify transform dialect strategies through
a symbol pointing to a library call. This is currently available through
two flags:

`--iree-codegen-use-transform-dialect-strategy=[@<symbol_name>|filename]`
  `--iree-codegen-transform-dialect-library=filename`

The transform library is loaded and cached in the IREE codegen dialect
for subsequent invocations within the MaterializeUserConfigs pass. Then,
the loaded dialect is immediately used with the symbol name referenced
by the transform dialect usage flag. If a filename is specified instead,
that is broadcasted to the transform dialect interpreter (intended for
microbenchmarking).

If the symbol applies successfully, this will send the result through
normal IREE codegen. This gives users the option to replace the
translation info on the export op with a `<None>` pipeline to send it
through <BACKEND>LowerExecutableTarget unperterbed (thereby skipping
the initial tile + distribute and bufferization).

Additionally this unifies the way the transform dialect testing flags
currently duplicated across backends.
  • Loading branch information
qedawkins authored Oct 25, 2023
1 parent 97a1394 commit 466e812
Show file tree
Hide file tree
Showing 67 changed files with 1,024 additions and 539 deletions.
160 changes: 82 additions & 78 deletions compiler/src/iree/compiler/Codegen/Common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -64,84 +64,6 @@ iree_gentbl_cc_library(
],
)

# TODO: If the layering causes concerns then the transform dialect interpreter
# should be one level above everything: it is a mechanism by which
# transformations are applied to any IR and needs to register all the dialects
# that may be produced.
# In particular, a single IREE-side transform interpreter is enough to perform
# all kind of transformations and not just codegen.
# This is an opportunity to retire the specific interpreter that is used for
# creating dispatch regions with the transform dialect, but only once the
# layering is correct.
iree_compiler_cc_library(
name = "TransformDialectInterpreterPass",
srcs = [
"TransformDialectInterpreterPass.cpp",
],
deps = [
":PassHeaders",
":PassesIncGen",
# Dialects
"//compiler/src/iree/compiler/Codegen/Dialect:IREECodegenDialect",
"//compiler/src/iree/compiler/Dialect/Flow/IR",
"//llvm-external-projects/iree-dialects:IREELinalgExtDialect",
"//llvm-external-projects/iree-dialects:IREELinalgExtTransformOps",
"//llvm-external-projects/iree-dialects:IREELinalgTransformDialect",
"@llvm-project//mlir:AffineDialect",
"@llvm-project//mlir:AffineUtils",
"@llvm-project//mlir:AsyncDialect",
"@llvm-project//mlir:ArithDialect",
"@llvm-project//mlir:ArithUtils",
"@llvm-project//mlir:BufferizationDialect",
"@llvm-project//mlir:BufferizationTransforms",
"@llvm-project//mlir:FuncDialect",
"@llvm-project//mlir:GPUDialect",
"@llvm-project//mlir:LinalgDialect",
"@llvm-project//mlir:LLVMDialect",
"@llvm-project//mlir:PDLDialect",
"@llvm-project//mlir:PDLInterpDialect",
"@llvm-project//mlir:SCFDialect",
"@llvm-project//mlir:SCFUtils",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TransformDialect",
"@llvm-project//mlir:TransformDialectTransforms",
"@llvm-project//mlir:VectorDialect",
# IR
"@llvm-project//mlir:Analysis",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Rewrite",
# Interfaces
# Transforms (needed mostly for the BufferizableOpInterfaceImpl)
"@llvm-project//mlir:ArithTransforms",
"@llvm-project//mlir:LinalgTransforms",
"@llvm-project//mlir:SCFTransforms",
"@llvm-project//mlir:TensorTransforms",
"@llvm-project//mlir:VectorTransforms",
# Other Stuff
"//compiler/src/iree/compiler/Utils",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:DialectUtils",
# TransformStrategies
"//compiler/src/iree/compiler/Codegen/TransformStrategies/Common:TransformStrategies",
# TransformExtensions (needed for registration in the pass)
"//llvm-external-projects/iree-dialects:IREEDialectsTransforms",
"//compiler/src/iree/compiler/Codegen/Common/TransformExtensions:CommonExtensions",
"//compiler/src/iree/compiler/Dialect/Flow/TransformExtensions:FlowExtensions",
"//compiler/src/iree/compiler/Codegen/LLVMCPU/TransformExtensions:LLVMCPUExtensions",
"//compiler/src/iree/compiler/Codegen/LLVMGPU/TransformExtensions:LLVMGPUExtensions",
"@llvm-project//mlir:AffineTransformOps",
"@llvm-project//mlir:BufferizationTransformOps",
"@llvm-project//mlir:GPUTransformOps",
"@llvm-project//mlir:LinalgTransformOps",
"@llvm-project//mlir:MemRefTransformOps",
"@llvm-project//mlir:SCFTransformOps",
"@llvm-project//mlir:TensorTransformOps",
"@llvm-project//mlir:VectorTransformOps",
],
)

iree_compiler_cc_library(
name = "Common",
srcs = [
Expand Down Expand Up @@ -271,3 +193,85 @@ iree_compiler_cc_library(
"@llvm-project//mlir:ViewLikeInterface",
],
)

# TODO: If the layering causes concerns then the transform dialect interpreter
# should be one level above everything: it is a mechanism by which
# transformations are applied to any IR and needs to register all the dialects
# that may be produced.
# In particular, a single IREE-side transform interpreter is enough to perform
# all kind of transformations and not just codegen.
# This is an opportunity to retire the specific interpreter that is used for
# creating dispatch regions with the transform dialect, but only once the
# layering is correct.
iree_compiler_cc_library(
name = "TransformDialectInterpreterPass",
srcs = [
"CommonDialectRegistration.cpp",
"MaterializeUserConfigs.cpp",
"TransformDialectInterpreterPass.cpp",
],
deps = [
":Common",
":PassHeaders",
":PassesIncGen",
# Dialects
"//compiler/src/iree/compiler/Codegen/Dialect:IREECodegenDialect",
"//compiler/src/iree/compiler/Dialect/Flow/IR",
"//llvm-external-projects/iree-dialects:IREELinalgExtDialect",
"//llvm-external-projects/iree-dialects:IREELinalgExtTransformOps",
"//llvm-external-projects/iree-dialects:IREELinalgTransformDialect",
"@llvm-project//mlir:AffineDialect",
"@llvm-project//mlir:AffineUtils",
"@llvm-project//mlir:AsyncDialect",
"@llvm-project//mlir:ArithDialect",
"@llvm-project//mlir:ArithUtils",
"@llvm-project//mlir:BufferizationDialect",
"@llvm-project//mlir:BufferizationTransforms",
"@llvm-project//mlir:FuncDialect",
"@llvm-project//mlir:GPUDialect",
"@llvm-project//mlir:LinalgDialect",
"@llvm-project//mlir:LLVMDialect",
"@llvm-project//mlir:PDLDialect",
"@llvm-project//mlir:PDLInterpDialect",
"@llvm-project//mlir:SCFDialect",
"@llvm-project//mlir:SCFUtils",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TransformDialect",
"@llvm-project//mlir:TransformDialectTransforms",
"@llvm-project//mlir:VectorDialect",
# IR
"@llvm-project//mlir:Analysis",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Rewrite",
# Interfaces
# Transforms (needed mostly for the BufferizableOpInterfaceImpl)
"@llvm-project//mlir:ArithTransforms",
"@llvm-project//mlir:LinalgTransforms",
"@llvm-project//mlir:SCFTransforms",
"@llvm-project//mlir:TensorTransforms",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:VectorTransforms",
# Other Stuff
"//compiler/src/iree/compiler/Utils",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:DialectUtils",
# TransformStrategies
"//compiler/src/iree/compiler/Codegen/TransformStrategies/Common:TransformStrategies",
# TransformExtensions (needed for registration in the pass)
"//llvm-external-projects/iree-dialects:IREEDialectsTransforms",
"//compiler/src/iree/compiler/Codegen/Common/TransformExtensions:CommonExtensions",
"//compiler/src/iree/compiler/Dialect/Flow/TransformExtensions:FlowExtensions",
"//compiler/src/iree/compiler/Codegen/LLVMCPU/TransformExtensions:LLVMCPUExtensions",
"//compiler/src/iree/compiler/Codegen/LLVMGPU/TransformExtensions:LLVMGPUExtensions",
"@llvm-project//mlir:AffineTransformOps",
"@llvm-project//mlir:BufferizationTransformOps",
"@llvm-project//mlir:GPUTransformOps",
"@llvm-project//mlir:LinalgTransformOps",
"@llvm-project//mlir:MemRefTransformOps",
"@llvm-project//mlir:SCFTransformOps",
"@llvm-project//mlir:TensorTransformOps",
"@llvm-project//mlir:VectorTransformOps",
],
)
126 changes: 65 additions & 61 deletions compiler/src/iree/compiler/Codegen/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,67 +47,6 @@ iree_tablegen_library(
--gen-rewriters FoldTensorExtractOp.cpp.inc
)

iree_cc_library(
NAME
TransformDialectInterpreterPass
SRCS
"TransformDialectInterpreterPass.cpp"
DEPS
::PassHeaders
::PassesIncGen
IREEDialectsTransforms
IREELinalgExtDialect
IREELinalgExtTransformOps
IREELinalgTransformDialect
LLVMSupport
MLIRAffineDialect
MLIRAffineTransformOps
MLIRAffineUtils
MLIRAnalysis
MLIRArithDialect
MLIRArithTransforms
MLIRArithUtils
MLIRAsyncDialect
MLIRBufferizationDialect
MLIRBufferizationTransformOps
MLIRBufferizationTransforms
MLIRFuncDialect
MLIRGPUDialect
MLIRGPUTransformOps
MLIRIR
MLIRLLVMDialect
MLIRLinalgDialect
MLIRLinalgTransformOps
MLIRLinalgTransforms
MLIRMemRefTransformOps
MLIRPDLDialect
MLIRPDLInterpDialect
MLIRPass
MLIRRewrite
MLIRSCFDialect
MLIRSCFTransformOps
MLIRSCFTransforms
MLIRSCFUtils
MLIRSupport
MLIRTensorDialect
MLIRTensorTransformOps
MLIRTensorTransforms
MLIRTransformDialect
MLIRTransformDialectTransforms
MLIRVectorDialect
MLIRVectorTransformOps
MLIRVectorTransforms
iree::compiler::Codegen::Common::TransformExtensions::CommonExtensions
iree::compiler::Codegen::Dialect::IREECodegenDialect
iree::compiler::Codegen::LLVMCPU::TransformExtensions::LLVMCPUExtensions
iree::compiler::Codegen::LLVMGPU::TransformExtensions::LLVMGPUExtensions
iree::compiler::Codegen::TransformStrategies::Common::TransformStrategies
iree::compiler::Dialect::Flow::IR
iree::compiler::Dialect::Flow::TransformExtensions::FlowExtensions
iree::compiler::Utils
PUBLIC
)

iree_cc_library(
NAME
Common
Expand Down Expand Up @@ -236,4 +175,69 @@ iree_cc_library(
PUBLIC
)

iree_cc_library(
NAME
TransformDialectInterpreterPass
SRCS
"CommonDialectRegistration.cpp"
"MaterializeUserConfigs.cpp"
"TransformDialectInterpreterPass.cpp"
DEPS
::Common
::PassHeaders
::PassesIncGen
IREEDialectsTransforms
IREELinalgExtDialect
IREELinalgExtTransformOps
IREELinalgTransformDialect
LLVMSupport
MLIRAffineDialect
MLIRAffineTransformOps
MLIRAffineUtils
MLIRAnalysis
MLIRArithDialect
MLIRArithTransforms
MLIRArithUtils
MLIRAsyncDialect
MLIRBufferizationDialect
MLIRBufferizationTransformOps
MLIRBufferizationTransforms
MLIRFuncDialect
MLIRGPUDialect
MLIRGPUTransformOps
MLIRIR
MLIRLLVMDialect
MLIRLinalgDialect
MLIRLinalgTransformOps
MLIRLinalgTransforms
MLIRMemRefTransformOps
MLIRPDLDialect
MLIRPDLInterpDialect
MLIRPass
MLIRRewrite
MLIRSCFDialect
MLIRSCFTransformOps
MLIRSCFTransforms
MLIRSCFUtils
MLIRSupport
MLIRTensorDialect
MLIRTensorTransformOps
MLIRTensorTransforms
MLIRTransformDialect
MLIRTransformDialectTransforms
MLIRTransforms
MLIRVectorDialect
MLIRVectorTransformOps
MLIRVectorTransforms
iree::compiler::Codegen::Common::TransformExtensions::CommonExtensions
iree::compiler::Codegen::Dialect::IREECodegenDialect
iree::compiler::Codegen::LLVMCPU::TransformExtensions::LLVMCPUExtensions
iree::compiler::Codegen::LLVMGPU::TransformExtensions::LLVMGPUExtensions
iree::compiler::Codegen::TransformStrategies::Common::TransformStrategies
iree::compiler::Dialect::Flow::IR
iree::compiler::Dialect::Flow::TransformExtensions::FlowExtensions
iree::compiler::Utils
PUBLIC
)

### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
Loading

0 comments on commit 466e812

Please sign in to comment.