diff options
author | Aart Bik <39774503+aartbik@users.noreply.github.com> | 2023-12-12 15:34:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-12 15:34:31 -0800 |
commit | 365777ecbe18777431681fb54d068885044c6ef1 (patch) | |
tree | 5459d9bfa058ddb962da0b1fb153a8b2cc841ea4 | |
parent | 8eff5704829ba5edd28754fd9ec7665b34fde22a (diff) | |
download | llvm-365777ecbe18777431681fb54d068885044c6ef1.zip llvm-365777ecbe18777431681fb54d068885044c6ef1.tar.gz llvm-365777ecbe18777431681fb54d068885044c6ef1.tar.bz2 |
[mlir][sparse] refactor utilities into transform/utils dir (#75250)
Separates actual transformation files from supporting utility files in
the transforms directory. Includes a bazel overlay fix for the build (as
well as a bit of cleanup of that file to be less verbose and more
flexible).
21 files changed, 76 insertions, 85 deletions
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt b/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt index 8459e46..ad8b0d0 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt @@ -1,9 +1,6 @@ add_mlir_dialect_library(MLIRSparseTensorTransforms + # Rewriting. BufferizableOpInterfaceImpl.cpp - CodegenEnv.cpp - CodegenUtils.cpp - IterationGraphSorter.cpp - LoopEmitter.cpp SparseBufferRewriting.cpp SparseGPUCodegen.cpp SparseReinterpretMap.cpp @@ -12,11 +9,16 @@ add_mlir_dialect_library(MLIRSparseTensorTransforms SparseTensorConversion.cpp SparseTensorPasses.cpp SparseTensorRewriting.cpp - SparseTensorDescriptor.cpp SparseVectorization.cpp Sparsification.cpp SparsificationAndBufferizationPass.cpp StageSparseOperations.cpp + # Utilities. + Utils/CodegenEnv.cpp + Utils/CodegenUtils.cpp + Utils/IterationGraphSorter.cpp + Utils/LoopEmitter.cpp + Utils/SparseTensorDescriptor.cpp ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SparseTensor diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp index cdbf4f0..248e941 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "CodegenUtils.h" +#include "Utils/CodegenUtils.h" #include "mlir/Dialect/Arith/IR/Arith.h" #include "mlir/Dialect/Func/IR/FuncOps.h" diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp index 5155cab..477ff2e 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp @@ -13,8 +13,8 @@ // //===----------------------------------------------------------------------===// -#include "CodegenUtils.h" -#include "LoopEmitter.h" +#include "Utils/CodegenUtils.h" +#include "Utils/LoopEmitter.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/GPU/IR/GPUDialect.h" diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp index 488079c..f2e1b0b 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "CodegenUtils.h" -#include "IterationGraphSorter.h" +#include "Utils/CodegenUtils.h" +#include "Utils/IterationGraphSorter.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp index a6f4dd3..91dad05 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "CodegenUtils.h" +#include "Utils/CodegenUtils.h" #include "mlir/Conversion/LLVMCommon/StructBuilder.h" #include "mlir/Dialect/SparseTensor/IR/SparseTensorStorageLayout.h" diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp index 18b2bb0..491501a 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp @@ -15,8 +15,8 @@ // //===----------------------------------------------------------------------===// -#include "CodegenUtils.h" -#include "SparseTensorDescriptor.h" +#include "Utils/CodegenUtils.h" +#include "Utils/SparseTensorDescriptor.h" #include "mlir/Dialect/Arith/Utils/Utils.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp index e6052f2..b0447b2 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp @@ -16,7 +16,7 @@ // //===----------------------------------------------------------------------===// -#include "CodegenUtils.h" +#include "Utils/CodegenUtils.h" #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp index 4fc692f..3b9685b 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#include "CodegenUtils.h" -#include "LoopEmitter.h" +#include "Utils/CodegenUtils.h" +#include "Utils/LoopEmitter.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arith/IR/Arith.h" diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp index 561c4e2..7710a44 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp @@ -16,8 +16,8 @@ // //===----------------------------------------------------------------------===// -#include "CodegenUtils.h" -#include "LoopEmitter.h" +#include "Utils/CodegenUtils.h" +#include "Utils/LoopEmitter.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arith/IR/Arith.h" diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp index 2367d3b..934e1e5 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp @@ -10,9 +10,9 @@ // //===----------------------------------------------------------------------===// -#include "CodegenEnv.h" -#include "CodegenUtils.h" -#include "LoopEmitter.h" +#include "Utils/CodegenEnv.h" +#include "Utils/CodegenUtils.h" +#include "Utils/LoopEmitter.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Arith/IR/Arith.h" diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.cpp index 4bd3af2..4bd3af2 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.cpp diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.h index cd626041..cd626041 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.h +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.h diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp index 33d449a..33d449a 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.h index 57de437..57de437 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.h +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.h diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/IterationGraphSorter.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.cpp index b601172..b601172 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/IterationGraphSorter.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.cpp diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/IterationGraphSorter.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.h index 52ee117..52ee117 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/IterationGraphSorter.h +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.h diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp index 08d37b6..08d37b6 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h index fa8b007..fa8b007 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.h +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorDescriptor.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp index 3ab4157..3ab4157 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorDescriptor.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorDescriptor.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.h index 5c7d8aa..5c7d8aa 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorDescriptor.h +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.h diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel index 2e3bb8a..200998a 100644 --- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel @@ -2773,13 +2773,9 @@ cc_library( td_library( name = "SparseTensorTdFiles", - srcs = [ - "include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td", - "include/mlir/Dialect/SparseTensor/IR/SparseTensorBase.td", - "include/mlir/Dialect/SparseTensor/IR/SparseTensorInterfaces.td", - "include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td", - "include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.td", - ], + srcs = glob([ + "include/mlir/Dialect/SparseTensor/IR/*.td", + ]), includes = ["include"], deps = [ ":InferTypeOpInterfaceTdFiles", @@ -2788,15 +2784,6 @@ td_library( ], ) -td_library( - name = "SparseTensorInterfacesTdFiles", - srcs = [ - "include/mlir/Dialect/SparseTensor/IR/SparseTensorInterfaces.td", - ], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - gentbl_cc_library( name = "SparseTensorAttrDefsIncGen", tbl_outs = [ @@ -2918,7 +2905,37 @@ gentbl_cc_library( ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/SparseTensor/IR/SparseTensorInterfaces.td", - deps = [":SparseTensorInterfacesTdFiles"], + deps = [":SparseTensorTdFiles"], +) + +td_library( + name = "SparseTensorTransformOpsTdFiles", + srcs = glob([ + "include/mlir/Dialect/SparseTensor/TransformOps/*.td", + ]), + includes = ["include"], + deps = [ + ":TransformDialectTdFiles", + ], +) + +gentbl_cc_library( + name = "SparseTensorTransformOpsIncGen", + tbl_outs = [ + ( + ["-gen-op-decls"], + "include/mlir/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.h.inc", + ), + ( + ["-gen-op-defs"], + "include/mlir/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.cpp.inc", + ), + ], + tblgen = ":mlir-tblgen", + td_file = "include/mlir/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.td", + deps = [ + ":SparseTensorTransformOpsTdFiles", + ], ) # This library is shared by both SparseTensorDialect and @@ -2932,19 +2949,11 @@ cc_library( cc_library( name = "SparseTensorDialect", - srcs = [ - "lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.cpp", - "lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.h", - "lib/Dialect/SparseTensor/IR/Detail/DimLvlMapParser.cpp", - "lib/Dialect/SparseTensor/IR/Detail/DimLvlMapParser.h", - "lib/Dialect/SparseTensor/IR/Detail/LvlTypeParser.cpp", - "lib/Dialect/SparseTensor/IR/Detail/LvlTypeParser.h", - "lib/Dialect/SparseTensor/IR/Detail/TemplateExtras.h", - "lib/Dialect/SparseTensor/IR/Detail/Var.cpp", - "lib/Dialect/SparseTensor/IR/Detail/Var.h", - "lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp", - "lib/Dialect/SparseTensor/IR/SparseTensorInterfaces.cpp", - ], + srcs = glob([ + "lib/Dialect/SparseTensor/IR/*.cpp", + "lib/Dialect/SparseTensor/IR/Detail/*.cpp", + "lib/Dialect/SparseTensor/IR/Detail/*.h", + ]), hdrs = [ "include/mlir/Dialect/SparseTensor/IR/SparseTensor.h", "include/mlir/Dialect/SparseTensor/IR/SparseTensorInterfaces.h", @@ -2987,40 +2996,14 @@ cc_library( ], ) -td_library( - name = "SparseTensorTransformOpsTdFiles", - srcs = glob([ - "include/mlir/Dialect/SparseTensor/TransformOps/*.td", - ]), - includes = ["include"], - deps = [ - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "SparseTensorTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.td", - deps = [ - ":SparseTensorTransformOpsTdFiles", - ], -) - cc_library( name = "SparseTensorUtils", - srcs = glob(["lib/Dialect/SparseTensor/Utils/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/SparseTensor/Utils/*.h"]), + srcs = glob([ + "lib/Dialect/SparseTensor/Utils/*.cpp", + ]), + hdrs = glob([ + "include/mlir/Dialect/SparseTensor/Utils/*.h", + ]), includes = ["include"], deps = [ ":ArithDialect", @@ -3039,6 +3022,8 @@ cc_library( srcs = glob([ "lib/Dialect/SparseTensor/Transforms/*.cpp", "lib/Dialect/SparseTensor/Transforms/*.h", + "lib/Dialect/SparseTensor/Transforms/Utils/*.cpp", + "lib/Dialect/SparseTensor/Transforms/Utils/*.h", ]), hdrs = [ "include/mlir/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.h", @@ -3081,8 +3066,12 @@ cc_library( cc_library( name = "SparseTensorPipelines", - srcs = glob(["lib/Dialect/SparseTensor/Pipelines/*.cpp"]), - hdrs = ["include/mlir/Dialect/SparseTensor/Pipelines/Passes.h"], + srcs = glob([ + "lib/Dialect/SparseTensor/Pipelines/*.cpp", + ]), + hdrs = [ + "include/mlir/Dialect/SparseTensor/Pipelines/Passes.h", + ], includes = ["include"], local_defines = if_cuda_available(["MLIR_GPU_TO_CUBIN_PASS_ENABLE"]), deps = [ |