Skip to content

Commit eced4a8

Browse files
committed
[mlir] [sparse] start of sparse tensor compiler support
As discussed in https://llvm.discourse.group/t/mlir-support-for-sparse-tensors/2020 this CL is the start of sparse tensor compiler support in MLIR. Starting with a "dense" kernel expressed in the Linalg dialect together with per-dimension sparsity annotations on the tensors, the compiler automatically lowers the kernel to sparse code using the methods described in Fredrik Kjolstad's thesis. Many details are still TBD. For example, the sparse "bufferization" is purely done locally since we don't have a global solution for propagating sparsity yet. Furthermore, code to input and output the sparse tensors is missing. Nevertheless, with some hand modifications, the generated MLIR can be easily converted into runnable code already. Reviewed By: nicolasvasilache, ftynse Differential Revision: https://reviews.llvm.org/D90994
1 parent 792f8e1 commit eced4a8

File tree

9 files changed

+3859
-0
lines changed

9 files changed

+3859
-0
lines changed

mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,12 @@ LogicalResult applyStagedPatterns(
771771
const FrozenRewritePatternList &stage2Patterns,
772772
function_ref<LogicalResult(Operation *)> stage3Lambda = nullptr);
773773

774+
//===----------------------------------------------------------------------===//
775+
// Support for sparse tensor code generation.
776+
//===----------------------------------------------------------------------===//
777+
void populateSparsificationPatterns(MLIRContext *context,
778+
OwningRewritePatternList &patterns);
779+
774780
} // namespace linalg
775781
} // namespace mlir
776782

mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ add_mlir_dialect_library(MLIRLinalgTransforms
99
Interchange.cpp
1010
Loops.cpp
1111
Promotion.cpp
12+
Sparsification.cpp
1213
Tiling.cpp
1314
Transforms.cpp
1415
Vectorization.cpp

0 commit comments

Comments
 (0)