[mlir][sparse] Add new option (enable-runtime-library) to sparse compiler pipeline

Add new option (enable-runtime-library) to sparse compiler pipeline, it allows us to decide whether we need to rewrite operations (e.g., concatenate, reshape) within sparsification (when using codegen) or convert them after sparsification (when using runtime library).

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133597
This commit is contained in:
Peiming Liu
2022-09-09 18:37:59 +00:00
parent c7f64616e9
commit eb65327fe9
7 changed files with 82 additions and 14 deletions

View File

@@ -47,17 +47,19 @@ struct SparsificationPass
vectorLength = options.vectorLength;
enableSIMDIndex32 = options.enableSIMDIndex32;
enableVLAVectorization = options.enableVLAVectorization;
enableRuntimeLibrary = options.enableRuntimeLibrary;
}
void runOnOperation() override {
auto *ctx = &getContext();
// Apply pre-rewriting.
RewritePatternSet prePatterns(ctx);
populateSparseTensorRewriting(prePatterns);
(void)applyPatternsAndFoldGreedily(getOperation(), std::move(prePatterns));
// Translate strategy flags to strategy options.
SparsificationOptions options(parallelization, vectorization, vectorLength,
enableSIMDIndex32, enableVLAVectorization);
enableSIMDIndex32, enableVLAVectorization,
enableRuntimeLibrary);
// Apply pre-rewriting.
populateSparseTensorRewriting(prePatterns, options.enableRuntimeLibrary);
(void)applyPatternsAndFoldGreedily(getOperation(), std::move(prePatterns));
// Apply sparsification and vector cleanup rewriting.
RewritePatternSet patterns(ctx);
populateSparsificationPatterns(patterns, options);