[Mlir-commits] [mlir] 365777e - [mlir][sparse] refactor utilities into transform/utils dir (#75250)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Dec 12 15:34:35 PST 2023
Author: Aart Bik
Date: 2023-12-12T15:34:31-08:00
New Revision: 365777ecbe18777431681fb54d068885044c6ef1
URL: https://github.com/llvm/llvm-project/commit/365777ecbe18777431681fb54d068885044c6ef1
DIFF: https://github.com/llvm/llvm-project/commit/365777ecbe18777431681fb54d068885044c6ef1.diff
LOG: [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).
Added:
mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.cpp
mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.h
mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp
mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.h
mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.cpp
mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.h
mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h
mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp
mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.h
Modified:
mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt
mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp
mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
Removed:
mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.cpp
mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.h
mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp
mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.h
mlir/lib/Dialect/SparseTensor/Transforms/IterationGraphSorter.cpp
mlir/lib/Dialect/SparseTensor/Transforms/IterationGraphSorter.h
mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.cpp
mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.h
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorDescriptor.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorDescriptor.h
################################################################################
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt b/mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt
index 8459e46e5814f0..ad8b0d02eca35e 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 cdbf4f048a00f3..248e9413b6e0dc 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 5155cab772d440..477ff2e1c9237e 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 488079cfe4e32d..f2e1b0bc58f132 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 a6f4dd3c2f7185..91dad050b28852 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 18b2bb0819e264..491501a3381b9c 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 e6052f2ca894c2..b0447b2436619e 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 4fc692f2fe9ddc..3b9685b8ae1e07 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 561c4e25114602..7710a44a7ca052 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 2367d3b5f37ade..934e1e559f44d6 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
similarity index 100%
rename from mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.cpp
rename to 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
similarity index 100%
rename from mlir/lib/Dialect/SparseTensor/Transforms/CodegenEnv.h
rename to 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
similarity index 100%
rename from mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp
rename to 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
similarity index 100%
rename from mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.h
rename to 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
similarity index 100%
rename from mlir/lib/Dialect/SparseTensor/Transforms/IterationGraphSorter.cpp
rename to 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
similarity index 100%
rename from mlir/lib/Dialect/SparseTensor/Transforms/IterationGraphSorter.h
rename to 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
similarity index 100%
rename from mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.cpp
rename to 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
similarity index 100%
rename from mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.h
rename to 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
similarity index 100%
rename from mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorDescriptor.cpp
rename to 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
similarity index 100%
rename from mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorDescriptor.h
rename to 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 2e3bb8ad40b7cb..200998a3bf2052 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 = [
More information about the Mlir-commits
mailing list