summaryrefslogtreecommitdiff
path: root/mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp
AgeCommit message (Collapse)Author
2025-11-20[MLIR] Apply clang-tidy fixes for bugprone-argument-comment in ↵Mehdi Amini
SparseBufferRewriting.cpp (NFC)
2025-08-27[MLIR] Apply clang-tidy fixes for misc-use-internal-linkage in ↵Mehdi Amini
SparseBufferRewriting.cpp (NFC)
2025-07-25[mlir][NFC] update `mlir/Dialect` create APIs (33/n) (#150659)Maksim Levental
See https://github.com/llvm/llvm-project/pull/147168 for more info.
2025-07-25[mlir][NFC] Use `getDefiningOp<OpTy>()` instead of ↵Longsheng Mou
`dyn_cast<OpTy>(getDefiningOp())` (#150428) This PR uses `val.getDefiningOp<OpTy>()` to replace `dyn_cast<OpTy>(val.getDefiningOp())` , `dyn_cast_or_null<OpTy>(val.getDefiningOp())` and `dyn_cast_if_present<OpTy>(val.getDefiningOp())`.
2025-07-22[mlir][NFC] update `mlir/Dialect` create APIs (21/n) (#149928)Maksim Levental
See https://github.com/llvm/llvm-project/pull/147168 for more info.
2024-08-04[mlir] Construct SmallVector with ArrayRef (NFC) (#101896)Kazu Hirata
2023-12-12[mlir][sparse] refactor utilities into transform/utils dir (#75250)Aart Bik
Separates actual transformation files from supporting utility files in the transforms directory. Includes a bazel overlay fix for the build (as well as a bit of cleanup of that file to be less verbose and more flexible).
2023-12-07[mlir][SparseTensor] Fix insertion point in `createQuickSort` (#74549)Matthias Springer
`createQuickSort` used to generate invalid IR: ``` "func.func"() <{function_type = (index, index, memref<?xindex>, memref<?xf32>, memref<?xi32>) -> (), sym_name = "_sparse_qsort_0_1_index_coo_1_f32_i32", sym_visibility = "private"}> ({ ^bb0(%arg0: index, %arg1: index, %arg2: memref<?xindex>, %arg3: memref<?xf32>, %arg4: memref<?xi32>): %0:2 = "scf.while"(%arg0, %arg1) ({ ^bb0(%arg5: index, %arg6: index): // ... "scf.condition"(%3, %arg5, %arg6) : (i1, index, index) -> () }, { ^bb0(%arg5: index, %arg6: index): // ... %7:2 = "scf.if"(%6) ({ %8 = "arith.cmpi"(%2, %3) <{predicate = 7 : i64}> : (index, index) -> i1 // ... "scf.yield"(%9#0, %9#1) : (index, index) -> () %10 = "arith.constant"() <{value = 0 : index}> : () -> index }, { "scf.yield"(%arg5, %arg5) : (index, index) -> () }) : (i1) -> (index, index) "scf.yield"(%7#0, %7#1) : (index, index) -> () }) : (index, index) -> (index, index) "func.return"() : () -> () }) : () -> () within split at mlir/test/Dialect/SparseTensor/buffer_rewriting.mlir:76 offset :11:1: error: 'scf.yield' op must be the last operation in the parent block ``` This commit fixes tests such as `mlir/test/Dialect/SparseTensor/buffer_rewriting.mlir` when verifying the IR after each pattern application (#74270).
2023-11-14[mlir][affine][nfc] cleanup deprecated T.cast style functions (#71269)long.chen
detail see the docment: https://mlir.llvm.org/deprecation/ Not all changes are made manually, most of them are made through a clang tool I wrote https://github.com/lipracer/cpp-refactor.
2023-10-03[mlir][sparse] renaming sparse_tensor.sort_coo to sparse_tensor.sort (#68161)Peiming Liu
Rationale: the operation does not always sort COO tensors (also used for sparse_tensor.compress for example).
2023-09-19[mlir][sparse] unifies sparse_tensor.sort_coo/sort into one operation. (#66722)Peiming Liu
The use cases of the two operations are largely overlapped, let's simplify it and only use one of them.
2023-09-18[mlir][sparse] fix logical error when generating sort_coo. (#66690)Peiming Liu
To fix issue: https://github.com/llvm/llvm-project/issues/66664
2023-03-15[mlir][sparse] Modify the pivot selection method for quick sort.bixia1
Previously, we choose the median of three values. We now choose the median of five values when the number of values being sorted exceed a threshold (currently 100). This is similar to std::sort. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D145534
2023-03-14[mlir][sparse] Improve sort operation by generating inlined code to compare ↵bixia1
values. Previously, we generate function calls to compare values for sorting. It turns out that the compiler doesn't inline those function calls. We now directly generate inlined code. Also, modify the code for comparing values to use less number of branches. This improves all sort implementation in general. For arabic-2005.mtx CSR, the improvement is around 25%. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D145442
2023-03-10[mlir][sparse] Improve quick sort by using a loop to sort the bigger partition.bixia1
Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D145440
2023-02-27[mlir][sparse] Add checking parent op of SortOpKohei Yamaguchi
Fix crash with segmentation fault caused by setting a parent operator that is not func::FuncOp with sparse_tensor SortOp. fixes https://github.com/llvm/llvm-project/issues/59988 Reviewed By: aartbik, wrengr Differential Revision: https://reviews.llvm.org/D143874
2023-02-08[mlir][sparse] Implement hybrid quick sort for sparse_tensor.sort.bixia1
Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D143227
2023-02-02[mlir][sparse] Implement heap sort for sparse_tensor.sort.bixia1
Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D142913
2023-01-31[mlir][sparse] Extend sorting function generator to support operand beyond ↵bixia1
(lo, hi, xs, ys). This is to prepare for implementing a hybrid quick sort, which switches to heap sort when the recursive depth exceeds certain limits. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D142731
2023-01-29[mlir][sparse] Extend sparse_tensor.sort with a enum attribute to specify a ↵bixia1
sorting implementation. Currently, all the non-stable sorting algorithms are implemented via the straightforward quick sort. This will be fixed in the following PR. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D142678
2023-01-29[mlir][sparse] Change the quick sort pivot selection.bixia1
Previously, we choose the value at (lo + hi)/2 as a pivot for partitioning the data in [lo, hi). We now choose the median for the three values at lo, (lo + hi)/2, and (hi-1) as a pivot to match the std::qsort implementation. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D142679
2023-01-25[mlir][sparse] (re)introducing getRankedTensorType/getMemrefTypewren romano
The bulk of D142074 seems to have gotten overwritten due to some sort of merge conflict (afaict there's no record of it having been reverted intentionally). So this commit redoes those changes. In addition to the original changes, this commit also: * moves the definition of `getRankedTensorType` (from `Transforms/CodegenUtils.h` to `IR/SparseTensor.h`), so that it can be used by `IR/SparseTensorDialect.cpp`. * adds `getMemRefType` as another abbreviation. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D142503
2022-12-23[mlir][sparse] use sparse_tensor::StorageSpecifier to store dim/memSizesPeiming Liu
Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D140130
2022-12-08[mlir][sparse] Fix problems in creating complex zero for initialization.bixia1
Reviewed By: aartbik, wrengr Differential Revision: https://reviews.llvm.org/D139591
2022-11-21Merge kDynamicSize and kDynamicSentinel into one constant.Aliia Khasanova
resolve conflicts Differential Revision: https://reviews.llvm.org/D138282
2022-11-15[mlir][sparse] avoid single small vector, set exact number 3Aart Bik
Reviewed By: wrengr Differential Revision: https://reviews.llvm.org/D138071
2022-11-15[mlir][sparse] cleanup small vector constant hintsAart Bik
Following advise from https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h This revision removes the size hints from SmallVector (unless we are certain of the resulting number of elements). Also, this replaces SmallVector references with SmallVectorImpl references. Reviewed By: Peiming Differential Revision: https://reviews.llvm.org/D138063
2022-11-14[mlir][sparse] Add rewriting rules for sparse_tensor.sort_coo.bixia1
Refactor the rewriting of sparse_tensor.sort to support the implementation of sparse_tensor.sort_coo. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D137522
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-11-07[mlir][sparse] Improve the non-stable sort implementation.bixia1
Replace the quick sort partition method with one that is more similar to the method used by C++ std quick sort. This improves the runtime for sorting sk_2005.mtx by more than 10x. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D137290
2022-10-31[mlir][sparse] Implement the rewrite for sparse_tensor.push_back a value n ↵bixia1
times. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D136654
2022-10-13Apply clang-tidy fixes for readability-identifier-naming in ↵Mehdi Amini
SparseBufferRewriting.cpp (NFC)
2022-10-12Apply clang-tidy fixes for modernize-use-using in SparseBufferRewriting.cpp ↵Mehdi Amini
(NFC)
2022-10-06[mlir][sparse] Implement insertion sort for the stable sort operator.bixia1
Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D135182
2022-09-29[mlir][sparse] Allow the push_back operator to skip capacity check and ↵bixia1
reallocation. Add UnitAttr `inbounds` for this purpose. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D134913
2022-09-29[mlir][sparse] Move the implementation of sparse_tensor.push_back to the ↵bixia1
buffer rewriter. Reviewed By: aartbik, Peiming Differential Revision: https://reviews.llvm.org/D134777
2022-09-29[mlir][sparse] fix build breakage due to Arith name changeAart Bik
Reviewed By: Peiming Differential Revision: https://reviews.llvm.org/D134899
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