[Mlir-commits] [mlir] [mlir][sparse] expose emit strategy option to mini pipeline (PR #96238)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jun 20 14:13:24 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-sparse
@llvm/pr-subscribers-mlir
Author: Peiming Liu (PeimingLiu)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/96238.diff
3 Files Affected:
- (modified) mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td (+9)
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp (+3)
- (modified) mlir/test/Dialect/SparseTensor/sparse_iteration_to_scf.mlir (+1)
``````````diff
diff --git a/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td b/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td
index 7173cde67384b..75a479b898040 100644
--- a/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td
@@ -475,6 +475,15 @@ def SparsificationAndBufferization : Pass<"sparsification-and-bufferization", "M
"Enable i32 indexing into vectors (for efficient gather/scatter)">,
Option<"enableGPULibgen", "enable-gpu-libgen", "bool", "false",
"Enable GPU acceleration by means of direct library calls">,
+ Option<"sparseEmitStrategy", "sparse-emit-strategy", "mlir::SparseEmitStrategy",
+ "mlir::SparseEmitStrategy::kFunctional",
+ "Emit functional code or interfaces (to debug) for sparse loops", [{llvm::cl::values(
+ clEnumValN(mlir::SparseEmitStrategy::kFunctional, "functional",
+ "Emit functional code (with scf.for/while)."),
+ clEnumValN(mlir::SparseEmitStrategy::kSparseIterator, "sparse-iterator",
+ "Emit (experimental) loops (with sparse.iterate)."),
+ clEnumValN(mlir::SparseEmitStrategy::kDebugInterface, "debug-interface",
+ "Emit non-functional but easy-to-read interfaces to debug."))}]>,
];
}
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp
index 3ae6732f900fe..d6fae430922be 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp
@@ -120,6 +120,9 @@ class SparsificationAndBufferizationPass
}
void runOnOperation() override {
+ // Overrides the default emit strategy using user-provided value.
+ this->sparsificationOptions.sparseEmitStrategy = sparseEmitStrategy;
+
// Run enabling transformations.
{
OpPassManager pm("builtin.module");
diff --git a/mlir/test/Dialect/SparseTensor/sparse_iteration_to_scf.mlir b/mlir/test/Dialect/SparseTensor/sparse_iteration_to_scf.mlir
index 77a0e89dc7c81..6d8f9018ad3a5 100644
--- a/mlir/test/Dialect/SparseTensor/sparse_iteration_to_scf.mlir
+++ b/mlir/test/Dialect/SparseTensor/sparse_iteration_to_scf.mlir
@@ -1,5 +1,6 @@
// RUN: mlir-opt %s --lower-sparse-iteration-to-scf | FileCheck %s
// RUN: mlir-opt %s --sparse-space-collapse --lower-sparse-iteration-to-scf | FileCheck %s --check-prefix COLLAPSED
+// RUN: mlir-opt %s --sparsification-and-bufferization="sparse-emit-strategy=sparse-iterator" | FileCheck %s --check-prefix COLLAPSED
#COO = #sparse_tensor.encoding<{
map = (i, j) -> (
``````````
</details>
https://github.com/llvm/llvm-project/pull/96238
More information about the Mlir-commits
mailing list