[Mlir-commits] [mlir] [mlir][sparse] refactor utilities into transform/utils dir (PR #75250)
Aart Bik
llvmlistbot at llvm.org
Tue Dec 12 14:41:33 PST 2023
https://github.com/aartbik created https://github.com/llvm/llvm-project/pull/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).
>From d0924eed037867897c5b263a17e55ff8b7a951a9 Mon Sep 17 00:00:00 2001
From: Aart Bik <ajcbik at google.com>
Date: Tue, 12 Dec 2023 14:38:08 -0800
Subject: [PATCH] [mlir][sparse] refactor utilities into transform/utils dir
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).
---
.../Dialect/SparseTensor/Transforms/CMakeLists.txt | 12 +++++++-----
.../Transforms/SparseBufferRewriting.cpp | 2 +-
.../SparseTensor/Transforms/SparseGPUCodegen.cpp | 4 ++--
.../SparseTensor/Transforms/SparseReinterpretMap.cpp | 4 ++--
.../Transforms/SparseStorageSpecifierToLLVM.cpp | 2 +-
.../SparseTensor/Transforms/SparseTensorCodegen.cpp | 4 ++--
.../Transforms/SparseTensorConversion.cpp | 2 +-
.../Transforms/SparseTensorRewriting.cpp | 4 ++--
.../SparseTensor/Transforms/SparseVectorization.cpp | 4 ++--
.../SparseTensor/Transforms/Sparsification.cpp | 6 +++---
.../Transforms/{ => Utils}/CodegenEnv.cpp | 0
.../SparseTensor/Transforms/{ => Utils}/CodegenEnv.h | 0
.../Transforms/{ => Utils}/CodegenUtils.cpp | 0
.../Transforms/{ => Utils}/CodegenUtils.h | 0
.../Transforms/{ => Utils}/IterationGraphSorter.cpp | 0
.../Transforms/{ => Utils}/IterationGraphSorter.h | 0
.../Transforms/{ => Utils}/LoopEmitter.cpp | 0
.../Transforms/{ => Utils}/LoopEmitter.h | 0
.../{ => Utils}/SparseTensorDescriptor.cpp | 0
.../Transforms/{ => Utils}/SparseTensorDescriptor.h | 0
20 files changed, 23 insertions(+), 21 deletions(-)
rename mlir/lib/Dialect/SparseTensor/Transforms/{ => Utils}/CodegenEnv.cpp (100%)
rename mlir/lib/Dialect/SparseTensor/Transforms/{ => Utils}/CodegenEnv.h (100%)
rename mlir/lib/Dialect/SparseTensor/Transforms/{ => Utils}/CodegenUtils.cpp (100%)
rename mlir/lib/Dialect/SparseTensor/Transforms/{ => Utils}/CodegenUtils.h (100%)
rename mlir/lib/Dialect/SparseTensor/Transforms/{ => Utils}/IterationGraphSorter.cpp (100%)
rename mlir/lib/Dialect/SparseTensor/Transforms/{ => Utils}/IterationGraphSorter.h (100%)
rename mlir/lib/Dialect/SparseTensor/Transforms/{ => Utils}/LoopEmitter.cpp (100%)
rename mlir/lib/Dialect/SparseTensor/Transforms/{ => Utils}/LoopEmitter.h (100%)
rename mlir/lib/Dialect/SparseTensor/Transforms/{ => Utils}/SparseTensorDescriptor.cpp (100%)
rename mlir/lib/Dialect/SparseTensor/Transforms/{ => Utils}/SparseTensorDescriptor.h (100%)
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
More information about the Mlir-commits
mailing list