Skip to content

[mlir][sparse] allow unknown ops in one-shot bufferization in mini-pipeline #77688

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

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

aartbik
Copy link
Contributor

@aartbik aartbik commented Jan 10, 2024

Rationale:
Since this mini-pipeline may be used in alternative pipelines (viz. different from the default "sparsifier" pipeline) where unknown ops are handled by alternative bufferization methods that are downstream of this mini-pipeline, we allow unknown ops by default (failure to bufferize is eventually apparent by failing to convert to LLVM IR).

This is part of enabling e2e testing for TORCH-MLIR tests using a sparsifier backend

…mini-pipeline

Rationale:
Since this mini-pipeline may be used in alternative pipelines (viz.
different from the default "sparsifier" pipeline) where unknown ops
are handled by alternative bufferization methods that are downstream
of this mini-pipeline, we allow unknown ops by default (failure to
bufferize is eventually apparent by failing to convert to LLVM IR).
@llvmbot llvmbot added mlir:sparse Sparse compiler in MLIR mlir labels Jan 10, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 10, 2024

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-sparse

Author: Aart Bik (aartbik)

Changes

…mini-pipeline

Rationale:
Since this mini-pipeline may be used in alternative pipelines (viz. different from the default "sparsifier" pipeline) where unknown ops are handled by alternative bufferization methods that are downstream of this mini-pipeline, we allow unknown ops by default (failure to bufferize is eventually apparent by failing to convert to LLVM IR).


Full diff: https://github.com/llvm/llvm-project/pull/77688.diff

1 Files Affected:

  • (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp (+6)
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp
index 6266c63064ffbd..f497be6e48eba1 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp
@@ -201,6 +201,12 @@ mlir::getBufferizationOptionsForSparsification(bool analysisOnly) {
     options.testAnalysisOnly = true;
     options.printConflicts = true;
   }
+  // Since this mini-pipeline may be used in alternative pipelines (viz.
+  // different from the default "sparsifier" pipeline) where unknown ops
+  // are handled by alternative bufferization methods that are downstream
+  // of this mini-pipeline, we allow unknown ops by default (failure to
+  // bufferize is eventually apparent by failing to convert to LLVM IR).
+  options.allowUnknownOps = true;
   return options;
 }
 

@aartbik aartbik changed the title [mlir][sparse] allow unknown ops in one-shot bufferization in sparse … [mlir][sparse] allow unknown ops in one-shot bufferization in mini-pipeline Jan 10, 2024
@aartbik aartbik merged commit aec73ea into llvm:main Jan 10, 2024
@aartbik aartbik deleted the bik branch January 10, 2024 21:36
// are handled by alternative bufferization methods that are downstream
// of this mini-pipeline, we allow unknown ops by default (failure to
// bufferize is eventually apparent by failing to convert to LLVM IR).
options.allowUnknownOps = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just fyi: From a correctness perspective, setting allowUnknownOps = true is always safe. The main benefit of setting allowUnknownOps = false is that we get more descriptive error messages in case there are ops that cannot be bufferized (and are not lowered by subsequent passes). Bufferizing the entire IR with One-Shot Bufferize is generally more efficient. If an op is bufferized later, a buffer copy will likely be inserted by that pass (when buffering an op that writes to memory).

justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
…peline (llvm#77688)

Rationale:
Since this mini-pipeline may be used in alternative pipelines (viz.
different from the default "sparsifier" pipeline) where unknown ops are
handled by alternative bufferization methods that are downstream of this
mini-pipeline, we allow unknown ops by default (failure to bufferize is
eventually apparent by failing to convert to LLVM IR).

This is part of enabling e2e testing for TORCH-MLIR tests using a
sparsifier backend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:sparse Sparse compiler in MLIR mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants