[Mlir-commits] [mlir] [mlir][sparse] refactor utilities into transform/utils dir (PR #75250)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Dec 12 14:42:11 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-sparse

Author: Aart Bik (aartbik)

<details>
<summary>Changes</summary>

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).

---
Full diff: https://github.com/llvm/llvm-project/pull/75250.diff


20 Files Affected:

- (modified) mlir/lib/Dialect/SparseTensor/Transforms/CMakeLists.txt (+7-5) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp (+2-2) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp (+2-2) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp (+2-2) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp (+2-2) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp (+2-2) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp (+3-3) 
- (renamed) mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.cpp () 
- (renamed) mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenEnv.h () 
- (renamed) mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp () 
- (renamed) mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.h () 
- (renamed) mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.cpp () 
- (renamed) mlir/lib/Dialect/SparseTensor/Transforms/Utils/IterationGraphSorter.h () 
- (renamed) mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp () 
- (renamed) mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h () 
- (renamed) mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp () 
- (renamed) mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.h () 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/75250


More information about the Mlir-commits mailing list