summaryrefslogtreecommitdiff
path: root/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp
AgeCommit message (Collapse)Author
2025-08-16[mlir][SparseTensor] Simplify pipeline (#152908)Matthias Springer
This refactoring improves compilation time.
2025-02-17[MLIR][NFC] Retire `let constructor` for passes in Conversion directory ↵lorenzo chelini
(part1) (#127403) `let constructor` is deprecated since the table gen backend emits most of the glue logic to build a pass. This PR retires the td method for most (I need another pass) passes in the Conversion directory.
2025-02-03[mlir][Vector] Add UB conversions to different tests and pipelines (#125145)Diego Caballero
This PR adds the UB to LLVM/SPIR-V conversion pass to some pipelines and tests. This is in preparation to introducing the generation of `ub.poison` in Vector dialect transformations (first one in https://github.com/llvm/llvm-project/pull/125613). It should effectively be NFC at this point.
2024-12-20[mlir][CF] Split `cf-to-llvm` from `func-to-llvm` (#120580)Matthias Springer
Do not run `cf-to-llvm` as part of `func-to-llvm`. This commit fixes https://github.com/llvm/llvm-project/issues/70982. This commit changes the way how `func.func` ops are lowered to LLVM. Previously, the signature of the entire region (i.e., entry block and all other blocks in the `func.func` op) was converted as part of the `func.func` lowering pattern. Now, only the entry block is converted. The remaining block signatures are converted together with `cf.br` and `cf.cond_br` as part of `cf-to-llvm`. All unstructured control flow is not converted as part of a single pass (`cf-to-llvm`). `func-to-llvm` no longer deals with unstructured control flow. Also add more test cases for control flow dialect ops. Note: This PR is in preparation of #120431, which adds an additional GPU-specific lowering for `cf.assert`. This was a problem because `cf.assert` used to be converted as part of `func-to-llvm`. Note for LLVM integration: If you see failures, add `-convert-cf-to-llvm` to your pass pipeline.
2024-12-20[mlir] Fix integration tests after #120548 (#120706)Matthias Springer
This should have been part of #120548.
2024-11-21[mlir][bufferization] Remove `finalizing-bufferize` pass (#114154)Matthias Springer
The dialect conversion-based bufferization passes have been migrated to One-Shot Bufferize about two years ago. To clean up the code base, this commit removes the `finalizing-bufferize` pass, one of the few remaining parts of the old infrastructure. Most bufferization passes have already been removed. Note for LLVM integration: If you depend on this pass, migrate to One-Shot Bufferize or copy the pass to your codebase. Depends on #114152.
2024-08-30[mlir][sparse] add parallelization options to mini pipeline (#104233)Yinying Li
2024-08-27[mlir][vector] Rename LowerVectorToLLVM to ConvertVectorToLLVM (NFC) (#104785)Hugo Trachino
There was some inconsistency with ConvertVectorToLLVM Pass builder, files and option names. This patch aims to move all occurences to ConvertVectorToLLVM.
2024-06-20[mlir][sparse] expose emit strategy option to mini pipeline (#96238)Peiming Liu
2024-05-02[mlir][sparse] add linalg elt-wise fusion to sparsifier pipeline (#90924)Aart Bik
yields better IR in general, and all end-to-end tests pass!
2024-02-24[mlir][linalg] NFC: Use tablegen macro for pass constructors (#82892)Quinn Dawkins
This uses the tablegen macros for generating pass constructors, exposing pass options for fold-unit-extent-dims and linalg-detensorize. Additionally aligns some of the pass namings to their text counterpart. This includes an API change: createLinalgGeneralizationPass -> createLinalgGeneralizeNamedOpsPass
2024-01-04[mlir][sparse] minor comment edits in sparsifier pipeline (#77000)Aart Bik
2023-11-15Changed all code and comments that used the phrase "sparse compiler" to ↵Tim Harvey
instead use "sparsifier" (#71875) The changes in this p.r. mostly center around the tests that use the flag sparse_compiler (also: sparse-compiler).
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-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-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-09-14[mlir][gpu][NVPTX] Enable NVIDIA GPU JIT compilation path (#66220)Fabian Mora
This patch adds an NVPTX compilation path that enables JIT compilation on NVIDIA targets. The following modifications were performed: 1. Adding a format field to the GPU object attribute, allowing the translation attribute to use the correct runtime function to load the module. Likewise, a dictionary attribute was added to add any possible extra options. 2. Adding the `createObject` method to `GPUTargetAttrInterface`; this method returns a GPU object from a binary string. 3. Adding the function `mgpuModuleLoadJIT`, which is only available for NVIDIA GPUs, as there is no equivalent for AMD. 4. Adding the CMake flag `MLIR_GPU_COMPILATION_TEST_FORMAT` to specify the format to use during testing.
2023-09-11[mlir][gpu] Deprecate gpu::Serialization* passes. (#65857)Fabian Mora
Deprecate the `gpu-to-cubin` & `gpu-to-hsaco` passes in favor of the `TargetAttr` workflow. This patch removes remaining upstream uses of the aforementioned passes, including the option to use them in `mlir-opt`. A future patch will remove these passes entirely. The passes can be re-enabled in `mlir-opt` by adding the CMake flag: `-DMLIR_ENABLE_DEPRECATED_GPU_SERIALIZATION=1`.
2023-09-09Reland [mlir][test][gpu] Migrate CUDA tests to the TargetAttr compilation ↵Fabian Mora
workflow (llvm#65768) The revert happened due to a build bot failure that threw 'CUDA_ERROR_UNSUPPORTED_PTX_VERSION'. The failure's root cause was a pass using "+ptx76" for compilation and an old CUDA driver on the bot. This commit relands the patch with "+ptx60". Original Gh PR: #65768 Original commit message: Migrate tests referencing `gpu-to-cubin` to the new compilation workflow using `TargetAttrs`. The `test-lower-to-nvvm` pass pipeline was modified to use the new compilation workflow to simplify the introduction of future tests. The `createLowerGpuOpsToNVVMOpsPass` function was removed, as it didn't allow for passing all options available in the `ConvertGpuOpsToNVVMOp` pass.
2023-09-09Revert "[mlir][test][gpu] Migrate CUDA tests to the TargetAttr compilation ↵Fabian Mora
workflow (#65768) (#65848) This reverts commit d21b67293be15f8a89378e4785d70cc037866406.
2023-09-09[mlir][test][gpu] Migrate CUDA tests to the TargetAttr compilation workflow ↵Fabian Mora
(#65768) Migrate tests referencing `gpu-to-cubin` to the new compilation workflow using `TargetAttrs`. The `test-lower-to-nvvm` pass pipeline was modified to use the new compilation workflow to simplify the introduction of future tests. The `createLowerGpuOpsToNVVMOpsPass` function was removed, as it didn't allow for passing all options available in the `ConvertGpuOpsToNVVMOp` pass.
2023-09-05[mlir][memref] Add pass to expand realloc operations, simplify lowering to LLVMMartin Erhart
There are two motivations for this change: 1. It considerably simplifies adding support for the realloc operation to the new buffer deallocation pass by lowering the realloc such that no deallocation operation is inserted and the deallocation pass itself can insert that dealloc 2. The lowering is expressed on a higher level and thus easier to understand, and the lowerings of the memref operations it is composed of don't have to be duplicated in the MemRefToLLVM lowering (also see discussion in https://reviews.llvm.org/D133424) Reviewed By: springerm Differential Revision: https://reviews.llvm.org/D159430
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-07-24Revert "[mlir][gpu] Fallback to JIT compilation" "[mlir][gpu] Increase ↵Mehdi Amini
default SM version from 35 to 50" and "[mlir][gpu] Improving Cubin Serialization with ptxas Compiler" This reverts commit 2e0e00ed841951e358a85a871647be9b3a622f51 and reverts commit a6eb40692c795a9cc29266779ceca2e304141114 and reverts commit 585cbe3f639783bf0307b47504acbd205f135310. 15 tests are broken on the mlir-nvidia buildbot: 'cuModuleLoadData(&module, data)' failed with 'CUDA_ERROR_INVALID_SOURCE' 'cuModuleGetFunction(&function, module, name)' failed with 'CUDA_ERROR_INVALID_HANDLE' 'cuLaunchKernel(function, gridX, gridY, gridZ, blockX, blockY, blockZ, smem, stream, params, extra)' failed with 'CUDA_ERROR_INVALID_HANDLE' 'cuModuleUnload(module)' failed with 'CUDA_ERROR_INVALID_HANDLE'
2023-07-24[mlir][gpu] Improving Cubin Serialization with ptxas CompilerGuray Ozen
This work improves how we compile the generated PTX code using the `ptxas` compiler. Currently, we rely on the driver's jit API to compile the PTX code. However, this approach has some limitations. It doesn't always produce the same binary output as the ptxas compiler, leading to potential inconsistencies in the generated Cubin files. This work introduces a significant improvement by directly utilizing the ptxas compiler for PTX compilation. By doing so, we can achieve more consistent and reliable results in generating cubin files. Key Benefits: - Using the Ptxas compiler directly ensures that the cubin files generated during the build process remain consistent with CUDA compilation using `nvcc` or `clang`. - Another advantage of this work is that it allows developers to experiment with different ptxas compilers without the need to change the compiler. Performance among ptxas compiler versions are vary, therefore, one can easily try different ptxas compilers. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D155563
2023-05-12[mlir] Move casting calls from methods to function callsTres Popp
The MLIR classes Type/Attribute/Operation/Op/Value support cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast functionality in addition to defining methods with the same name. This change begins the migration of uses of the method to the corresponding function call as has been decided as more consistent. Note that there still exist classes that only define methods directly, such as AffineExpr, and this does not include work currently to support a functional cast/isa call. Caveats include: - This clang-tidy script probably has more problems. - This only touches C++ code, so nothing that is being generated. Context: - https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…" - Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443 Implementation: This first patch was created with the following steps. The intention is to only do automated changes at first, so I waste less time if it's reverted, and so the first mass change is more clear as an example to other teams that will need to follow similar steps. Steps are described per line, as comments are removed by git: 0. Retrieve the change from the following to build clang-tidy with an additional check: https://github.com/llvm/llvm-project/compare/main...tpopp:llvm-project:tidy-cast-check 1. Build clang-tidy 2. Run clang-tidy over your entire codebase while disabling all checks and enabling the one relevant one. Run on all header files also. 3. Delete .inc files that were also modified, so the next build rebuilds them to a pure state. 4. Some changes have been deleted for the following reasons: - Some files had a variable also named cast - Some files had not included a header file that defines the cast functions - Some files are definitions of the classes that have the casting methods, so the code still refers to the method instead of the function without adding a prefix or removing the method declaration at the same time. ``` ninja -C $BUILD_DIR clang-tidy run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\ -header-filter=mlir/ mlir/* -fix rm -rf $BUILD_DIR/tools/mlir/**/*.inc git restore mlir/lib/IR mlir/lib/Dialect/DLTI/DLTI.cpp\ mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp\ mlir/lib/**/IR/\ mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp\ mlir/lib/Dialect/Vector/Transforms/LowerVectorMultiReduction.cpp\ mlir/test/lib/Dialect/Test/TestTypes.cpp\ mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp\ mlir/test/lib/Dialect/Test/TestAttributes.cpp\ mlir/unittests/TableGen/EnumsGenTest.cpp\ mlir/test/python/lib/PythonTestCAPI.cpp\ mlir/include/mlir/IR/ ``` Differential Revision: https://reviews.llvm.org/D150123
2023-04-12[mlir][bufferization] Make function boundary type convertion logic dynamic.Oleg Shyshkov
Having to choose from only static or dynamic layout for all function is limiting. Differential Revision: https://reviews.llvm.org/D148074
2023-04-05[mlir][sparse][gpu] sparse GPU code generator pipeline setupAart Bik
Reviewed By: Peiming Differential Revision: https://reviews.llvm.org/D147571
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
2023-01-27[mlir][Conversion] Rename the MemRefToLLVM passQuentin Colombet
Since the recent MemRef refactoring that centralizes the lowering of complex MemRef operations outside of the conversion framework, the MemRefToLLVM pass doesn't directly convert these complex operations. Instead, to fully convert the whole MemRef dialect space, MemRefToLLVM needs to run after `expand-strided-metadata`. Make this more obvious by changing the name of the pass and the option associated with it from `convert-memref-to-llvm` to `finalize-memref-to-llvm`. The word "finalize" conveys that this pass needs to run after something else and that something else is documented in its tablegen description. This is a follow-up patch related to the conversation at: https://discourse.llvm.org/t/psa-you-need-to-run-expand-strided-metadata-before-memref-to-llvm-now/66956/14 Differential Revision: https://reviews.llvm.org/D142463
2022-12-14[mlir][sparse] Make the remaining integration tests run with vectorization.bixia1
Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D140057
2022-12-14[mlir][sparse] Add another call to ConvertVectorToLLVMPass, to lower the ↵bixia1
vector operations added by ConvertMathToLLVMPass. Run sparse_tanh with vectorization. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D139958
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-02Re-apply "[mlir][MemRefToLLVM] Remove the code for lowering subview"Quentin Colombet
This reverts commit d0650d108929985760d536d59e9927838dccc9b8. Original commit message: Subviews are supposed to be expanded before we hit the lowering code. The expansion is done with the pass called expand-strided-metadata. Add a test that demonstrate how these passes can be linked up to achieve the desired lowering. This patch is NFC in spirit but not in practice because `subview` gets lowered into `reinterpret_cast(extract_strided_metadata, <some math>)` which lowers in two memref descriptors (one for `reinterpert_cast` and one for `extract_strided_metadata`), which creates some noise of the form: `extractvalue(unrealized_cast(extractvalue[0]))[0]` that is currently not simplified within MLIR but that is really just noop in that case. Differential Revision: https://reviews.llvm.org/D136377
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
2022-11-21[mlir][bufferization] Support general Attribute as memory spaceLei Zhang
MemRef has been accepting a general Attribute as memory space for a long time. This commits updates bufferization side to catch up, which allows downstream users to plugin customized symbolic memory space. This also eliminates quite a few `getMemorySpaceAsInt` calls, which is deprecated. Reviewed By: springerm Differential Revision: https://reviews.llvm.org/D138330
2022-11-17[mlir][sparse] Split SparseTensorRewrite into PreSparsificationRewrite and ↵bixia1
PostSparsificationRewrite. Reviewed By: aartbik, wrengr Differential Revision: https://reviews.llvm.org/D138153
2022-11-14[mlir][sparse] avoid nop rewriting on runtime lib path in pipelineAart Bik
Reviewed By: Peiming Differential Revision: https://reviews.llvm.org/D137981
2022-11-14[MLIR][Transform] Expose map layout option in `OneShotBufferizeOp`Lorenzo Chelini
Expose `function-boundary-type-conversion` in `OneShotBufferizeOp`. To reuse options between passes and transform operations, create a `BufferizationEnums.td`. Reviewed By: springerm Differential Revision: https://reviews.llvm.org/D137833
2022-11-10[mlir][sparse] Add option enable-buffer-initialization to the ↵bixia1
sparse-tensor-codegen pass. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D137733
2022-11-08[mlir][sparse] Add option enable-buffer-initialization to initialize the ↵bixia1
memory buffers for sparse tensors to support debugging. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D137592
2022-10-29[mlir][sparse] run canonicalization pass after DenseOpBufferize.Peiming Liu
As pointed out by Matthias: "DenseBufferizationPass should be run right after TensorCopyInsertionPass. (Running it after bufferizing the sparse IR is also OK.) The reason for this is that whether copies are needed for not depends on the structure of the program (SSA use-def chains). In particular, running the canonicalizer in-between is problematic because it could introduce new RaW conflicts" Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D136980
2022-10-19[mlir][sparse] remove vector support in sparsificationPeiming Liu
Sparse compiler used to generate vectorized code for sparse tensors computation, but it should really be delegated to other vectorization passes for better progressive lowering. https://discourse.llvm.org/t/rfc-structured-codegen-beyond-rectangular-arrays/64707 Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D136183
2022-10-05[mlir][sparse] move sparse tensor rewriting into its own passAart Bik
Makes individual testing and debugging easier. Reviewed By: bixia Differential Revision: https://reviews.llvm.org/D135319
2022-09-29[mlir][sparse] Add rewrite rule for the sort operator.bixia1
Add sparse-buffer-rewrite pass to rewrite sparse primitives on buffers to MLIR implementation. Add sparse rewrite rule for the sort operator. Add FileCheck test and integration test. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D134627
2022-09-29[mlir][arith] Change dialect name from Arithmetic to ArithJakub Kuderski
Suggested by @lattner in https://discourse.llvm.org/t/rfc-define-precise-arith-semantics/65507/22. Tested with: `ninja check-mlir check-mlir-integration check-mlir-mlir-spirv-cpu-runner check-mlir-mlir-vulkan-runner check-mlir-examples` and `bazel build --config=generic_clang @llvm-project//mlir:all`. Reviewed By: lattner, Mogball, rriddle, jpienaar, mehdi_amini Differential Revision: https://reviews.llvm.org/D134762
2022-09-26[MLIR] Migrate MemRef -> LLVM conversion pass to the auto-generated constructorMichele Scuttari
See #57475 Differential Revision: https://reviews.llvm.org/D134607
2022-09-09[mlir][sparse] Add new option (enable-runtime-library) to sparse compiler ↵Peiming Liu
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
2022-08-30Revert "[MLIR] Update pass declarations to new autogenerated files"Michele Scuttari
This reverts commit 2be8af8f0e0780901213b6fd3013a5268ddc3359.
2022-08-30[MLIR] Update pass declarations to new autogenerated filesMichele Scuttari
The patch introduces the required changes to update the pass declarations and definitions to use the new autogenerated files and allow dropping the old infrastructure. Reviewed By: mehdi_amini, rriddle Differential Review: https://reviews.llvm.org/D132838