summaryrefslogtreecommitdiff
path: root/mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp
AgeCommit message (Collapse)Author
2025-11-08[mlir] Remove duplicate includes (NFC) (#167187)Kazu Hirata
Identified with readability-duplicate-include.
2025-07-28[mlir] Generalize OneShotModuleBufferize to operate on any Operation (#148327)Evan Liu
As part of 2646c36a864aa6a62bc1280e9a8cd2bcd2695349, `OneShotModuleBufferize` no longer descends into nested symbol tables, recommending users who wish to do this should do so in a pass pipeline/custom pass. This did not support the use case of ops that weren't ModuleOps. The patch updates `OneShotModuleBufferize` to work on any general op.
2025-07-12[mlir] Remove unused includes (NFC) (#148396)Kazu Hirata
2025-06-18[mlir][bufferization] Use Type instead of Value in unknown conversion (#144658)Andrei Golubev
Generally, bufferization should be able to create a memref from a tensor without needing to know more than just a mlir::Type. Thus, change BufferizationOptions::UnknownTypeConverterFn to accept just a type (mlir::TensorType for now) instead of mlir::Value. Additionally, apply the same rationale to getMemRefType() helper function. Both changes are prerequisites to enable custom types support in one-shot bufferization.
2025-05-28[MLIR] Add bufferization state to `getBufferType` and `resolveConflicts` ↵Michele Scuttari
interface methods (#141466) The PR continues the work started in #141019 by adding the `BufferizationState` class also to the `getBufferType` and `resolveConflicts` interface methods, together with the additional support functions that are used throughout the bufferization infrastructure.
2025-05-23[MLIR] Add bufferization state class to OneShotBufferization pass (#141019)Michele Scuttari
Follow-up on #138143, which was reverted due to a missing update a method signature (more specifically, the bufferization interface for `tensor::ConcatOp`) that was not catched before merging. The old PR description is reported in the next lines. This PR is a follow-up on https://github.com/llvm/llvm-project/pull/138125, and adds a bufferization state class providing information about the IR. The information currently consists of a cached list of symbol tables, which aims to solve the quadratic scaling of the bufferization task with respect to the number of symbols. The PR breaks API compatibility: the bufferize method of the BufferizableOpInterface has been enriched with a reference to a BufferizationState object. The bufferization state must be kept in a valid state by the interface implementations. For example, if an operation with the Symbol trait is inserted or replaced, its parent SymbolTable must be updated accordingly (see, for example, the bufferization of arith::ConstantOp, where the symbol table of the module gets the new global symbol inserted). Similarly, the invalidation of a symbol table must be performed if an operation with the SymbolTable trait is removed (this can be performed using the invalidateSymbolTable method, introduced in https://github.com/llvm/llvm-project/pull/138014).
2025-05-22Revert "[MLIR] Add bufferization state class to OneShotBufferization pass" ↵Michele Scuttari
(#141012) Reverts llvm/llvm-project#138143 The PR for the BufferizationState is temporarily reverted due to API incompatibilities that have been initially missed during the update and were not catched by PR checks.
2025-05-22[MLIR] Add bufferization state class to OneShotBufferization pass (#138143)Michele Scuttari
This PR is a follow-up on #138125, and adds a bufferization state class providing information about the IR. The information currently consists of a cached list of symbol tables, which aims to solve the quadratic scaling of the bufferization task with respect to the number of symbols. The PR breaks API compatibility: the `bufferize` method of the `BufferizableOpInterface` has been enriched with a reference to a `BufferizationState` object. The bufferization state must be kept in a valid state by the interface implementations. For example, if an operation with the `Symbol` trait is inserted or replaced, its parent `SymbolTable` must be updated accordingly (see, for example, the bufferization of `arith::ConstantOp`, where the symbol table of the module gets the new global symbol inserted). Similarly, the invalidation of a symbol table must be performed if an operation with the `SymbolTable` trait is removed (this can be performed using the `invalidateSymbolTable` method, introduced in #138014).
2024-08-30[mlir][sparse] add parallelization options to mini pipeline (#104233)Yinying Li
2024-06-20[mlir][sparse] expose emit strategy option to mini pipeline (#96238)Peiming Liu
2024-06-17[mlir][sparse] support sparsifying sparse kernels to sparse-iterator-based ↵Peiming Liu
loop (#95858)
2024-06-11[mlir][sparse] expose optimization flags to mini pipeline (#95158)Aart Bik
Some of the options only fed into the full sparse pipeline. However, some backends prefer to use the sparse minipipeline. This change exposes some important optimization flags to the pass as well. This prepares some SIMDization of PyTorch sparsified code.
2024-04-17[mlir][SparseTensor] Add missing dependent dialect to pass (#88870)Matthias Springer
This commit fixes the following error when stopping the sparse compiler pipeline after bufferization (e.g., with `test-analysis-only`): ``` LLVM ERROR: Building op `vector.print` but it isn't known in this MLIRContext: the dialect may not be loaded or this operation hasn't been added by the dialect. See also https://mlir.llvm.org/getting_started/Faq/#registered-loaded-dependent-whats-up-with-dialects-management ```
2024-01-10[mlir][sparse] allow unknown ops in one-shot bufferization in mini-pipeline ↵Aart Bik
(#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
2023-11-30[mlir][sparse] refactoring: using util functions to query the index to load ↵Peiming Liu
from position array for slice-driven loop. (#73986)
2023-11-14[mlir][sparse][gpu] re-enable all GPU libgen tests (#72185)Aart Bik
Previous change no longer properly used the GPU libgen pass (even though most tests still passed falling back to CPU). This revision puts the proper pass order into place. Also bit of a cleanup of CPU codegen vs. libgen setup.
2023-11-08[mlir][sparse] end-to-end matmul between Dense and BSR tensors (#71448)Peiming Liu
2023-11-01[mlir][sparse] first end-to-end linalg.generic op on BSR (#70880)Aart Bik
2023-10-30[mlir][sparse] implements tensor.insert on sparse tensors. (#70737)Peiming Liu
2023-10-30[mlir][sparse] split post-sparsification-rewriting into two passes. (#70727)Peiming Liu
2023-10-12[mlir][sparse] implement sparse_tensor.reorder_coo (#68916)Peiming Liu
As a side effect of the change, it also unifies the convertOp implementation between lib/codegen path.
2023-10-11[mlir][sparse] simplify ConvertOp rewriting rules (#68350)Peiming Liu
Canonicalize complex convertOp into multiple stages, such that it can either be done by a direct conversion or by sorting.
2023-10-09[mlir][sparse] Extract `StorageSpecifierToLLVMPass` from bufferization ↵Matthias Springer
pipeline (#68635) `StorageSpecifierToLLVMPass` does not have to be part of the bufferization mini pipeline. It can run after the bufferization pipeline. This is desirable because it keeps the bufferization pipeline smaller. Also fix incorrect bufferization API usage: `bufferizeOp` instead of `bufferizeModuleOp` was used, even though function boundaries were bufferized.
2023-10-09[mlir][bufferization][NFC] Simplify `bufferizeOp` function signature (#68625)Matthias Springer
Remove the `opFilter` and `copyBeforeWrite` function arguments. These options can already be configured in the `options` object.
2023-09-18[mlir][bufferization] Remove allow-return-allocs and create-deallocs pass ↵Martin Erhart
options, remove bufferization.escape attribute (#66619) This commit removes the deallocation capabilities of one-shot-bufferization. One-shot-bufferization should never deallocate any memrefs as this should be entirely handled by the ownership-based-buffer-deallocation pass going forward. This means the `allow-return-allocs` pass option will default to true now, `create-deallocs` defaults to false and they, as well as the escape attribute indicating whether a memref escapes the current region, will be removed. A new `allow-return-allocs-from-loops` option is added as a temporary workaround for some bufferization limitations.
2023-09-13Revert "[mlir][bufferization] Remove allow-return-allocs and create-deallocs ↵Martin Erhart
pass options, remove bufferization.escape attribute" This reverts commit 6a91dfedeb956dfa092a6a3f411e8b02f0d5d289. This caused problems in downstream projects. We are reverting to give them more time for integration.
2023-09-13[mlir][bufferization] Remove allow-return-allocs and create-deallocs pass ↵Martin Erhart
options, remove bufferization.escape attribute This is the first commit in a series with the goal to rework the BufferDeallocation pass. Currently, this pass heavily relies on copies to perform correct deallocations, which leads to very slow code and potentially high memory usage. Additionally, there are unsupported cases such as returning memrefs which this series of commits aims to add support for as well. This first commit removes the deallocation capabilities of one-shot-bufferization.One-shot-bufferization should never deallocate any memrefs as this should be entirely handled by the buffer-deallocation pass going forward. This means the allow-return-allocs pass option will default to true now, create-deallocs defaults to false and they, as well as the escape attribute indicating whether a memref escapes the current region, will be removed. The documentation should w.r.t. these pass option changes should also be updated in this commit. Reviewed By: springerm Differential Revision: https://reviews.llvm.org/D156662
2023-08-17[mlir][sparse] refactor sparsification and bufferization pass into proper TD ↵Aart Bik
pass Registering the SparsificationAndBufferization into a proper TD pass has the advantage that it can be invoked and tested in isolation. This change also moves some bufferization specific set up from the pipeline file into the pass file, keeping the logic more locally. Reviewed By: Peiming Differential Revision: https://reviews.llvm.org/D158219
2023-05-15[mlir][sparse][gpu] first implementation of the GPU libgen approachAart Bik
The sparse compiler now has two prototype strategies for GPU acceleration: * CUDA codegen: this converts sparsified code to CUDA threads * CUDA libgen: this converts pre-sparsified code to cuSPARSE library calls This revision introduces the first steps required for the second approach. Reviewed By: ThomasRaoux Differential Revision: https://reviews.llvm.org/D150170
2023-03-27[mlir][sparse] add create-sparse-deallocs options to match the ↵Peiming Liu
create-deallocs in BufferizationOption. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D147010
2022-12-23[mlir][sparse] add missing dependent dialect.Peiming Liu
Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D140595
2022-12-22[mlir][sparse] introduce sparse_tensor::StorageSpecifierToLLVM passPeiming Liu
Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D140122
2022-12-12[mlir][bufferize] Implement BufferizableOpInterface for tensor.emptyMatthias Springer
The op is not bufferizable but should be analyzable (for `EliminateEmptyTensors`, which uses the bufferization infrastructure). Also improve debugging functionality and error messages. Also adds a missing pass to the sparse pipeline. (tensor.empty should be replaced with bufferization.alloc_tensor, but it sometimes used to work without depending on how the tensor.empty is used. Now we always fail explicitly.)
2022-12-07[mlir][sparse] introduce sparse vectorization to the sparse compiler pipelineAart Bik
Reviewed By: Peiming Differential Revision: https://reviews.llvm.org/D139581
2022-12-07[mlir][sparse] Add dependence on bufferization.bixia1
Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D139571
2022-12-02[mlir][sparse][bufferization] cleanup bufferization attributes after ↵Peiming Liu
SparsificationAndBufferizationPass Reviewed By: aartbik, springerm Differential Revision: https://reviews.llvm.org/D139218
2022-12-02[mlir][bufferization] Make `TensorCopyInsertionPass` a test passMatthias Springer
TensorCopyInsertion should not have been exposed as a pass. This was a flaw in the original design. It is a preparation step for bufferization and certain transforms (that would otherwise be legal) are illegal between TensorCopyInsertion and actual rewrite to MemRef ops. Therefore, even if broken down as two separate steps internally, they should be exposed as a single pass. This change affects the sparse compiler, which uses `TensorCopyInsertionPass`. A new `SparsificationAndBufferizationPass` is added to replace all passes in the sparse tensor pipeline from `TensorCopyInsertionPass` until the actual bufferization (rewrite to memref/non-tensor). It is generally unsafe to run arbitrary passes in-between, in particular passes that hoist tensor ops out of loops or change SSA use-def chains along tensor ops. Differential Revision: https://reviews.llvm.org/D138915