Commit Graph

758 Commits

Author SHA1 Message Date
Aart Bik
22212ca745 [mlir][sparse] simplify some header code (#70989)
This is a first revision in a small series of changes that removes
duplications between direct encoding methods and sparse tensor type
wrapper methods (in favor of the latter abstraction, since it provides
more safety). The goal is to simply end up with "just" SparseTensorType
2023-11-02 09:31:11 -07:00
Peiming Liu
c0d78c4232 [mlir][sparse] Implement rewriters to reinterpret maps on alloc_tenso… (#70993)
…r operation
2023-11-01 18:15:11 -07:00
Peiming Liu
3426d330a7 [mlir][sparse] Implement rewriters to reinterpret maps on foreach (#70868) 2023-11-01 12:11:47 -07:00
Aart Bik
b19c40c579 [mlir][sparse] first end-to-end linalg.generic op on BSR (#70880) 2023-11-01 10:01:22 -07:00
Aart Bik
e599978760 [mlir][sparse] first proof-of-concept non-permutation rewriter (#70863)
Rather than extending sparsifier codegen with higher order
non-permutations, we follow the path of rewriting linalg generic ops
into higher order operations. That way, code generation will simply work
out of the box. This is a very first proof-of-concept rewriting of that
idea.
2023-10-31 16:19:27 -07:00
Peiming Liu
c81a2c058e [mlir][sparse] add helper class to implement common rewriter to re/demap sparse tensors. (#70750) 2023-10-31 12:35:52 -07:00
Christian Ulmann
dcae289d3a [MLIR][SparseTensor] Introduce opaque pointers in LLVM dialect lowering (#70570)
This commit changes the SparseTensor LLVM dialect lowering from using
`llvm.ptr<i8>` to `llvm.ptr`. This change ensures that the lowering now
properly relies on opaque pointers, instead of working with already type
erased i8 pointers.
2023-10-31 07:34:49 +01:00
Peiming Liu
ef100c228a [mlir][sparse] implements tensor.insert on sparse tensors. (#70737) 2023-10-30 16:04:41 -07:00
Peiming Liu
f82bee1367 [mlir][sparse] split post-sparsification-rewriting into two passes. (#70727) 2023-10-30 15:22:21 -07:00
Peiming Liu
7d608ee2bb [mlir][sparse] unify sparse_tensor.out rewriting rules (#70518) 2023-10-27 16:46:58 -07:00
Peiming Liu
6a93da9900 [mlir][sparse] add ReinterpretMapScopeOption for the pass (#70486) 2023-10-27 14:14:09 -07:00
Aart Bik
7cfac1bedd [mlir][sparse] add boilterplate code for a new reintepret map pass (#70393)
The interesting stuff is of course still coming ;-)
2023-10-26 17:57:46 -07:00
Peiming Liu
ef222988b4 [mlir][sparse] implements sparse_tensor.reinterpret_map (#70388) 2023-10-26 16:00:32 -07:00
Aart Bik
b1bb23991a [mlir][sparse] merger cleanup (#70371)
Implemented some TODOs and removed unlikely ones.
Comment cleanup
2023-10-26 12:46:23 -07:00
Aart Bik
740582fa4c [mlir][sparse] test for linalg tensor semantics (#70254)
This test used to be here, but somehow got lost while linalg rewrote
their interfaces. It is essential to test this on entry of
sparsification, however, since all subsequent analysis simply assumes
tensor types.

Fixes:
https://github.com/llvm/llvm-project/issues/64325
2023-10-25 14:07:38 -07:00
Peiming Liu
c780352de9 [mlir][sparse] implement sparse_tensor.lvl operation. (#69993) 2023-10-24 13:23:28 -07:00
Peiming Liu
43961264c8 [mlir][sparse] hoists alloca outside the outermost loop. (#70085) 2023-10-24 11:22:50 -07:00
Peiming Liu
e9fa1fdec9 [mlir][sparse] support CSR/BSR conversion (#69800) 2023-10-20 17:24:34 -07:00
Peiming Liu
6456e0bbbb [mlir][sparse] implement sparse_tensor.crd_translate operation (#69653) 2023-10-20 16:18:02 -07:00
Peiming Liu
6243d7d28b [mlir][sparse] fix stack overflow due to memref.alloca in loops (#69786) 2023-10-20 16:01:36 -07:00
Kazu Hirata
6461a824e4 [Transforms] Use llvm::erase_if (NFC) 2023-10-20 00:08:56 -07:00
Aart Bik
3d89c088af [mlir][sparse] support BSR for cuSPARSE (libgen path only) (#69646) 2023-10-19 16:56:52 -07:00
Aart Bik
f16cb0eade [mlir][sparse] connect MapRef's lvl2dim with latest AffineMap computation (#69540)
This makes sure

- GEN MAP dim=2 lvl=4
  (d0, d1) -> (d0 floordiv 2, d1 floordiv 2, d0 mod 2, d1 mod 2)
--
  (d0, d1, d2, d3) -> (d0 * 2 + d2, d1 * 2 + d3)

is indeed encoded as

MAP-REF (dim=2, lvl=4) isperm=0
  d2l = [ d0/2 d1/2 d0%2 d1%2 ]
  ld2 = [ l2+2*l0 l3+2*l1 ]
2023-10-18 18:00:56 -07:00
Aart Bik
306f4c306a [mlir][sparse] implement non-permutation MapRef encoding (#69406)
This enables reading block sparse from file using libgen! (and soon also
direct IR codegen)
2023-10-18 13:01:12 -07:00
Peiming Liu
71c97c735c [mlir][sparse] avoid tensor to memref conversion in sparse tensor rewri… (#69362)
…ting rules.
2023-10-17 11:34:06 -07:00
Peiming Liu
761c9dd927 [mlir][sparse] implementating stageSparseOpPass as an interface (#69022) 2023-10-17 10:54:44 -07:00
Peiming Liu
eb14f47bf1 [mlir][sparse][NFC] fix variable naming convension (#69232) 2023-10-16 10:51:28 -07:00
Aart Bik
d392073f67 [mlir][sparse] simplify reader construction of new sparse tensor (#69036)
Making the materialize-from-reader method part of the Swiss army knife
suite again removes a lot of redundant boiler plate code and unifies the
parameter setup into a single centralized utility. Furthermore, we now
have minimized the number of entry points into the library that need a
non-permutation map setup, simplifying what comes next
2023-10-16 10:25:37 -07:00
Aart Bik
bbecd422a9 [mlir][sparse] cleanup sparse tensor materialization parameter setup (#68956) 2023-10-13 09:41:53 -07:00
Aart Bik
2045cca0c3 [mlir][sparse] add a forwarding insertion to SparseTensorStorage (#68939) 2023-10-12 21:03:07 -07:00
Aart Bik
fbe47bf532 [mlir][sparse] remove dead code from utils (#68943) 2023-10-12 17:47:26 -07:00
Peiming Liu
f248d0b28d [mlir][sparse] implement sparse_tensor.reorder_coo (#68916)
As a side effect of the change, it also unifies the convertOp
implementation between lib/codegen path.
2023-10-12 13:22:45 -07:00
Peiming Liu
837a26f237 [mlir][sparse] fix unused variable warning on release build (#68824) 2023-10-11 10:47:58 -07:00
Peiming Liu
dda3dc5e38 [mlir][sparse] simplify ConvertOp rewriting rules (#68350)
Canonicalize complex convertOp into multiple stages, such that it can
either be done by a direct conversion or by sorting.
2023-10-11 09:34:11 -07:00
Matthias Springer
48a73bc455 [mlir][sparse] Extract StorageSpecifierToLLVMPass from bufferization 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 18:01:50 -07:00
Matthias Springer
9d34c05222 [mlir][bufferization][NFC] Simplify bufferizeOp function signature (#68625)
Remove the `opFilter` and `copyBeforeWrite` function arguments. These
options can already be configured in the `options` object.
2023-10-09 17:52:52 -07:00
Aart Bik
d5622decf1 [mlir][sparse] rename map utility (#68611)
Rename util genReaderBuffers -> genMapBuffers since it is no longer
specific to the reader, but all MapRef data in general.
2023-10-09 14:41:45 -07:00
Aart Bik
a942f7c86e [mlir][sparse] move variable into assert to avoid 'unused' error (#68604) 2023-10-09 09:11:26 -07:00
Aart Bik
b7188d2877 [mlir][sparse] replace specialized buffer setup with util code (#68461)
This completely centralizes all set up related to dim2lvl and lvl2dim
for the runtime library (and even parts of direct IR codegen) into one
place! And all comptatible with the MapRef data structure that should be
used in all remaining clients of dim2lvl and lvl2dim.

NOTE: the convert_x2y.mlir tests were becoming too overloaded
      so I decided to bring them back to the basics; if e.g.
      more coverage of the foreach is required, they should
      go into isolated smalle tests
2023-10-09 08:50:59 -07:00
Peiming Liu
0637440002 [mlir][sparse] introduce a pass to stage complex sparse operations in… (#68436)
…to simple steps
2023-10-06 14:23:18 -07:00
Aart Bik
d3af65358d [mlir][sparse] introduce MapRef, unify conversion/codegen for reader (#68360)
This revision introduces a MapRef, which will support a future
generalization beyond permutations (e.g. block sparsity). This revision
also unifies the conversion/codegen paths for the sparse_tensor.new
operation from file (eg. the readers). Note that more unification is
planned as well as general affine dim2lvl and lvl2dim (all marked with
TODOs).
2023-10-06 13:42:01 -07:00
Yinying Li
6280e23124 [mlir][sparse] Print new syntax (#68130)
Printing changes from `#sparse_tensor.encoding<{ lvlTypes = [
"compressed" ] }>` to `map = (d0) -> (d0 : compressed)`. Level
properties, ELL and slice are also supported.
2023-10-04 16:36:05 -04:00
Aart Bik
1964118ace [mlir][sparse] fix codegen header ordering of methods into sections (#68175) 2023-10-04 08:52:26 -07:00
Peiming Liu
0083f8338c [mlir][sparse] renaming sparse_tensor.sort_coo to sparse_tensor.sort (#68161)
Rationale: the operation does not always sort COO tensors (also used for
sparse_tensor.compress for example).
2023-10-03 16:28:25 -07:00
Peiming Liu
c3b01b4679 [mlir][sparse] unify lib/codegen rewriting rules for sparse tensor concatenation. (#68057) 2023-10-03 08:46:25 -07:00
Peiming Liu
bc878f70fc [mlir][sparse] unify lib/codegen rewriting rules for sparse tensor re… (#68049)
…shaping operations.
2023-10-02 17:06:22 -07:00
Yinying Li
2cb99df609 [mlir][sparse] Fix typos (#67859) 2023-10-02 11:07:38 -04:00
Yinying Li
d2e8517912 [mlir][sparse] Update Enum name for CompressedWithHigh (#67845)
Change CompressedWithHigh to LooseCompressed.
2023-10-02 11:06:40 -04:00
Aart Bik
3231a365c1 [mlir][sparse][gpu] add CSC to libgen GPU sparsification using cuSparse (#67713)
Add CSC, but also adds BSR as a future format. Coming soon!
2023-09-28 11:47:22 -07:00
Peiming Liu
6ca47eb49d [mlir][sparse] rename sparse_tensor.(un)pack to sparse_tensor.(dis)as… (#67717)
…semble

Pack/Unpack are overridden in many other places, rename the operations
to avoid confusion.
2023-09-28 11:01:10 -07:00