Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlir][sparse] add sparsification options to pretty print and debug s… #80205

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ enum class ReinterpretMapScope {
kExceptGeneric, // reinterprets operation other than linalg.generic
};

/// Defines a scope for reinterpret map pass.
enum class DebugSparseIteration {
kNone, // generate fully inlined (and functional) sparse iteration
PeimingLiu marked this conversation as resolved.
Show resolved Hide resolved
kInterfaceOnly, // generate only place-holder for sparse iteration
};

#define GEN_PASS_DECL
#include "mlir/Dialect/SparseTensor/Transforms/Passes.h.inc"

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

/// Options for the Sparsification pass.
struct SparsificationOptions {
SparsificationOptions(SparseParallelizationStrategy p, DebugSparseIteration d,
bool enableRT)
: parallelizationStrategy(p), debugSparseIteration(d),
enableRuntimeLibrary(enableRT) {}

SparsificationOptions(SparseParallelizationStrategy p, bool enableRT)
: parallelizationStrategy(p), enableRuntimeLibrary(enableRT) {}
: SparsificationOptions(p, DebugSparseIteration::kNone, enableRT) {}

SparsificationOptions()
: SparsificationOptions(SparseParallelizationStrategy::kNone, true) {}
: SparsificationOptions(SparseParallelizationStrategy::kNone,
DebugSparseIteration::kNone, true) {}

SparseParallelizationStrategy parallelizationStrategy;
DebugSparseIteration debugSparseIteration;
bool enableRuntimeLibrary;
};

Expand Down
7 changes: 7 additions & 0 deletions mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ def SparsificationPass : Pass<"sparsification", "ModuleOp"> {
clEnumValN(mlir::SparseParallelizationStrategy::kAnyStorageAnyLoop,
"any-storage-any-loop",
"Enable sparse parallelization for any storage and loop."))}]>,
Option<"debugSparseIteration", "debug-sparse-iteration", "mlir::DebugSparseIteration",
"mlir::DebugSparseIteration::kNone",
"Pretty print sparse loops to debug sparse iteration", [{llvm::cl::values(
clEnumValN(mlir::DebugSparseIteration::kNone, "none",
"Turn off pretty printing and generates functional code."),
PeimingLiu marked this conversation as resolved.
Show resolved Hide resolved
clEnumValN(mlir::DebugSparseIteration::kInterfaceOnly, "interface-only",
"Generate non-functional interfaces for sparse iteration."))}]>,
Option<"enableRuntimeLibrary", "enable-runtime-library", "bool",
"true", "Enable runtime library for manipulating sparse tensors">,
];
Expand Down
Loading