Skip to content

Commit ddaa607

Browse files
author
Peiming Liu
committed
[mlir][sparse] add sparsification options to pretty print and debug sparse iterations.
1 parent dad50fe commit ddaa607

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ enum class ReinterpretMapScope {
4747
kExceptGeneric, // reinterprets operation other than linalg.generic
4848
};
4949

50+
/// Defines a scope for reinterpret map pass.
51+
enum class DebugSparseIteration {
52+
kNone, // generate fully inlined (and functional) sparse iteration
53+
kInterfaceOnly, // generate only place-holder for sparse iteration
54+
};
55+
5056
#define GEN_PASS_DECL
5157
#include "mlir/Dialect/SparseTensor/Transforms/Passes.h.inc"
5258

@@ -74,11 +80,20 @@ std::unique_ptr<Pass> createPreSparsificationRewritePass();
7480

7581
/// Options for the Sparsification pass.
7682
struct SparsificationOptions {
83+
SparsificationOptions(SparseParallelizationStrategy p, DebugSparseIteration d,
84+
bool enableRT)
85+
: parallelizationStrategy(p), debugSparseIteration(d),
86+
enableRuntimeLibrary(enableRT) {}
87+
7788
SparsificationOptions(SparseParallelizationStrategy p, bool enableRT)
78-
: parallelizationStrategy(p), enableRuntimeLibrary(enableRT) {}
89+
: SparsificationOptions(p, DebugSparseIteration::kNone, enableRT) {}
90+
7991
SparsificationOptions()
80-
: SparsificationOptions(SparseParallelizationStrategy::kNone, true) {}
92+
: SparsificationOptions(SparseParallelizationStrategy::kNone,
93+
DebugSparseIteration::kNone, true) {}
94+
8195
SparseParallelizationStrategy parallelizationStrategy;
96+
DebugSparseIteration debugSparseIteration;
8297
bool enableRuntimeLibrary;
8398
};
8499

mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ def SparsificationPass : Pass<"sparsification", "ModuleOp"> {
130130
clEnumValN(mlir::SparseParallelizationStrategy::kAnyStorageAnyLoop,
131131
"any-storage-any-loop",
132132
"Enable sparse parallelization for any storage and loop."))}]>,
133+
Option<"debugSparseIteration", "debug-sparse-iteration", "mlir::DebugSparseIteration",
134+
"mlir::DebugSparseIteration::kNone",
135+
"Pretty print sparse loops to debug sparse iteration", [{llvm::cl::values(
136+
clEnumValN(mlir::DebugSparseIteration::kNone, "none",
137+
"Turn off pretty printing and generates functional code."),
138+
clEnumValN(mlir::DebugSparseIteration::kInterfaceOnly, "interface-only",
139+
"Generate non-functional interfaces for sparse iteration."))}]>,
133140
Option<"enableRuntimeLibrary", "enable-runtime-library", "bool",
134141
"true", "Enable runtime library for manipulating sparse tensors">,
135142
];

0 commit comments

Comments
 (0)