Commit Graph

325 Commits

Author SHA1 Message Date
Matthias Springer
95d6aa21fb [mlir][SparseTensor][NFC] Use tensor.empty for dense tensors (#74804)
Use `tensor.empty` + initialization for dense tensors instead of
`bufferization.alloc_tensor`.
2023-12-12 08:56:47 +09:00
Aart Bik
21213f39e2 [mlir][sparse] fix uninitialized dense tensor out in conv2d test (#74884)
Note, tensor.empty may feed into SPARSE output (meaning it truly has no
values yet), but for a DENSE output, it should always have an initial
value. We ran a verifier over all our tests and this is the only
remaining omission.
2023-12-08 12:44:57 -08:00
Aart Bik
ec9e49796d [mlir][sparse] add sparse convolution with 5x5 kernel (#74793)
Also unifies some of the test set up parts in other conv tests
2023-12-07 18:11:04 -08:00
Aart Bik
7003e255d3 [mlir][sparse] code formatting (NFC) (#74779) 2023-12-07 15:46:24 -08:00
Peiming Liu
78e2b74f96 [mlir][sparse] fix bugs when generate sparse conv_3d kernels. (#74561) 2023-12-06 15:59:10 -08:00
Peiming Liu
8206b75a1e [mlir][sparse] fix crash when generate rotated convolution kernels. (#74146) 2023-12-01 14:13:57 -08:00
Aart Bik
1944c4f76b [mlir][sparse] rename DimLevelType to LevelType (#73561)
The "Dim" prefix is a legacy left-over that no longer makes sense, since
we have a very strict "Dimension" vs. "Level" definition for sparse
tensor types and their storage.
2023-11-27 14:27:52 -08:00
Aart Bik
c97e4273e2 [mlir][sparse] test on read/convert permuted 3d sparse tensors (#72925)
3! = 6
2023-11-21 09:26:04 -08:00
Peiming Liu
b52eb7c2fe [mlir][sparse] add a csr x bsr matmul test case (#73012) 2023-11-21 09:14:45 -08:00
Aart Bik
6352a07ba6 [mlir][sparse] test four row/col major versions of BSR (#72898)
Note, this is a redo of https://github.com/llvm/llvm-project/pull/72712
which was reverted due to time outs in the bot. I have timed the tests
on various settings, and it does not even hit the top 20 of integration
tests. To be safe, I removed the SIMD version of the tests, just keeping
libgen/direcIR paths (which are the most important to test for us).

I will also keep an eye on
https://lab.llvm.org/buildbot/#/builders/264/builds after submitting to
make sure there is no repeat.
2023-11-20 12:28:16 -08:00
Mehdi Amini
2b71f91b06 Revert "[mlir][sparse] stress test BSR" (#72735)
Reverts llvm/llvm-project#72712

This causes timeouts on the bots.
2023-11-17 19:06:49 -08:00
Aart Bik
813aaf39f9 [mlir][sparse] stress test BSR (#72712)
I always enjoy a good stress test. This end-to-end integration test
ensures the major ordering of both the block and within the block are
correctly handled (giving row-row, row-col, col-row and col-row as
options).
2023-11-17 15:47:38 -08:00
Aart Bik
6b56dd6a93 [mlir][sparse] enable 2:4 test for both directIR/libgen path (#72593) 2023-11-17 09:40:32 -08:00
Aart Bik
83cf0dc982 [mlir][sparse] implement direct IR alloc/empty/new for non-permutations (#72585)
This change implements the correct *level* sizes set up for the direct
IR codegen fields in the sparse storage scheme. This brings libgen and
codegen together again.

This is step 3 out of 3 to make sparse_tensor.new work for BSR
2023-11-16 17:17:41 -08:00
Aart Bik
58090617c6 [mlir][sparse] fix broken test (merge conflict marker was left) (#72438) 2023-11-15 13:01:43 -08:00
Tim Harvey
dce7a7cf69 Changed all code and comments that used the phrase "sparse compiler" to 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-15 20:12:35 +00:00
Aart Bik
a40900211a [mlir][sparse] set rwx permissions to consistent values (#72311)
some files had "x" permission set, others were missing "r"
2023-11-14 13:32:55 -08:00
Peiming Liu
269685545e [mlir][sparse] remove filter-loop based algorithm support to handle a… (#71840)
…ffine subscript expressions.
2023-11-13 11:36:49 -08:00
Aart Bik
af8428c0d9 [mlir][sparse] unify support of (dis)assemble between direct IR/lib path (#71880)
Note that the (dis)assemble operations still make some simplfying
assumptions (e.g. trailing 2-D COO in AoS format) but now at least both
the direct IR and support library path behave exactly the same.

Generalizing the ops is still TBD.
2023-11-13 10:05:00 -08:00
Peiming Liu
bfe08c094d [mlir][sparse] support sparsifying 2:4 block sparsity (#71749) 2023-11-10 12:25:53 -08:00
Peiming Liu
a2d9d2e1d9 [mlir][sparse] re-enable aarch64 test. (#71855)
Should have been fixed by initializing output tensor to zeros in
https://github.com/llvm/llvm-project/pull/71845
2023-11-09 11:46:52 -08:00
Peiming Liu
30e4b09d49 [mlir][sparse] try fix flanky test. (#71845) 2023-11-09 11:10:59 -08:00
Peiming Liu
4eb01f7d5e [mlir][sparse] disable aarch64 test to fix buildbot error. (#71818)
To fix https://github.com/llvm/llvm-project/pull/71448
2023-11-09 10:50:58 -08:00
Peiming Liu
c99951d491 [mlir][sparse] end-to-end matmul between Dense and BSR tensors (#71448) 2023-11-08 11:28:00 -08:00
Tim Harvey
c43e627457 Changed the phrase sparse-compiler to sparsifier in comments (#71578)
When the Powers That Be decided that the name "sparse compiler" should
be changed to "sparsifier", we negected to change some of the comments
in the code; this pull request completes the name change.
2023-11-07 20:55:00 +00:00
Aart Bik
160d483b1f [mlir][sparse] implement loose-compressed/2:4 on direct IR codegen path (#71461)
Fills in the missing cases for direct IR codegen.
Note that non-permutation handling is still TBD.
2023-11-06 17:30:56 -08:00
Christian Ulmann
52491c99fa [MLIR][LLVM] Remove typed pointer remnants from integration tests (#71208)
This commit removes all LLVM dialect typed pointers from the integration
tests. Typed pointers have been deprecated for a while now and it's
planned to soon remove them from the LLVM dialect.

Related PSA:
https://discourse.llvm.org/t/psa-removal-of-typed-pointers-from-the-llvm-dialect/74502
2023-11-03 21:21:25 +01:00
Peiming Liu
53ffafb24d [mlir][sparse] support sparse constant to BSR conversion. (#71114)
support direct convert from a constant tensor defined by
SparseArrayElements to BSR
2023-11-02 14:45:39 -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
Aart Bik
b19c40c579 [mlir][sparse] first end-to-end linalg.generic op on BSR (#70880) 2023-11-01 10:01:22 -07:00
Peiming Liu
ef222988b4 [mlir][sparse] implements sparse_tensor.reinterpret_map (#70388) 2023-10-26 16:00:32 -07:00
Aart Bik
e6005d5a9c [mlir][sparse] support 2:4 structured sparsity and loose compressed (#69968)
This adds library support for these two new level formats.
2023-10-23 15:34:45 -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
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
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
Yinying Li
d2e8517912 [mlir][sparse] Update Enum name for CompressedWithHigh (#67845)
Change CompressedWithHigh to LooseCompressed.
2023-10-02 11:06:40 -04: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
Yinying Li
256ac4619b [mlir][sparse] Change tests to use new syntax for ELL and slice (#67569)
Examples:

1. `#ELL = #sparse_tensor.encoding<{ lvlTypes = [ "dense", "dense",
"compressed" ], dimToLvl = affine_map<(i,j)[c] -> (c*4*i, i, j)>
}>`
to
`#ELL = #sparse_tensor.encoding<{ map = [s0](d0, d1) -> (d0 * (s0 * 4) :
dense, d0 : dense, d1 : compressed)
}>`

2. `#CSR_SLICE = #sparse_tensor.encoding<{ lvlTypes = [ "dense",
"compressed" ], dimSlices = [ (1, 4, 1), (1, 4, 2) ]
}>`
to
`#CSR_SLICE = #sparse_tensor.encoding<{ map = (d0 :
#sparse_tensor<slice(1, 4, 1)>, d1 : #sparse_tensor<slice(1, 4, 2)>) ->
(d0 : dense, d1 : compressed)
}>`
2023-09-27 19:40:52 -04:00
Yinying Li
d374a78545 [mlir][sparse] Treat high and 2OutOf4 as level formats (#67203)
In the new syntax, we will parse **loose_compressed** as
**CompressedWithHigh** and **block2_4** as **TwoOutOfFour** level
format. Currently, we support unique and order as level properties.
2023-09-25 11:04:55 -04:00
Peiming Liu
bfa3bc4378 [mlir][sparse] unifies sparse_tensor.sort_coo/sort into one operation. (#66722)
The use cases of the two operations are largely overlapped, let's
simplify it and only use one of them.
2023-09-19 17:02:32 -07:00
Peiming Liu
4176ce61f1 [mlir][sparse] fix logical error when generating sort_coo. (#66690)
To fix issue: https://github.com/llvm/llvm-project/issues/66664
2023-09-18 15:26:01 -07:00
Yinying Li
3dc621124f [mlir][sparse] Migrate tests to use new syntax (#66543)
**COO**
`lvlTypes = [ "compressed_nu", "singleton" ]` to `map = (d0, d1) -> (d0
: compressed(nonunique), d1 : singleton)`
`lvlTypes = [ "compressed_nu_no", "singleton_no" ]` to `map = (d0, d1)
-> (d0 : compressed(nonunique, nonordered), d1 : singleton(nonordered))`

**SortedCOO**
`lvlTypes = [ "compressed_nu", "singleton" ]` to `map = (d0, d1) -> (d0
: compressed(nonunique), d1 : singleton)`

**BCOO**
`lvlTypes = [ "dense", "compressed_hi_nu", "singleton" ]` to `map = (d0,
d1, d2) -> (d0 : dense, d1 : compressed(nonunique, high), d2 :
singleton)`

**BCSR**
`lvlTypes = [ "compressed", "compressed", "dense", "dense" ], dimToLvl =
affine_map<(d0, d1) -> (d0 floordiv 2, d1 floordiv 3, d0 mod 2, d1 mod
3)>` to
`map = ( i, j ) ->
      ( i floordiv 2 : compressed,
        j floordiv 3 : compressed,
        i mod 2 : dense,
        j mod 3 : dense
      )`

**Tensor and other supported formats(e.g. CCC, CDC, CCCC)**

Currently, ELL and slice are not supported yet in the new syntax and the
CHECK tests will be updated once printing is set to output the new
syntax.

Previous PRs: #66146, #66309, #66443
2023-09-15 16:12:20 -04:00
Aart Bik
d2e787d5d7 [mlir][sparse][tensor] replace bufferization with empty tensor (#66450)
Rationale:
    A bufferization.alloc_tensor can be directly replaced
    with tensor.empty since these are more or less semantically
    equivalent. The latter is considered a bit more "pure"
    with respect to SSA semantics.
2023-09-15 11:45:42 -07:00
Yinying Li
2a07f0fd40 [mlir][sparse] Migrate more tests to use new syntax (#66443)
**Dense**
`lvlTypes = [ "dense", "dense" ]` to `map = (d0, d1) -> (d0 : dense, d1
: dense)`
`lvlTypes = [ "dense", "dense" ], dimToLvl = affine_map<(i,j) -> (j,i)>`
to `map = (d0, d1) -> (d1 : dense, d0 : dense)`

**DCSR**
`lvlTypes = [ "compressed", "compressed" ]` to `map = (d0, d1) -> (d0 :
compressed, d1 : compressed)`

**DCSC**
`lvlTypes = [ "compressed", "compressed" ], dimToLvl = affine_map<(i,j)
-> (j,i)>` to `map = (d0, d1) -> (d1 : compressed, d0 : compressed)`

**Block Row**
`lvlTypes = [ "compressed", "dense" ]` to `map = (d0, d1) -> (d0 :
compressed, d1 : dense)`

**Block Column**
`lvlTypes = [ "compressed", "dense" ], dimToLvl = affine_map<(i,j) ->
(j,i)>` to `map = (d0, d1) -> (d1 : compressed, d0 : dense)`

This is an ongoing effort: #66146, #66309
2023-09-14 23:19:57 +00:00
Yinying Li
e2e429d994 [mlir][sparse] Migrate more tests to new syntax (#66309)
CSR:
`lvlTypes = [ "dense", "compressed" ]` to `map = (d0, d1) -> (d0 :
dense, d1 : compressed)`

CSC:
`lvlTypes = [ "dense", "compressed" ], dimToLvl = affine_map<(d0, d1) ->
(d1, d0)>` to `map = (d0, d1) -> (d1 : dense, d0 : compressed)`

This is an ongoing effort: #66146
2023-09-14 12:21:13 -04:00
Peiming Liu
098f46dce3 [sparse] allow unpack op to return 0-ranked tensor type. (#66269)
Many frontends canonicalize scalar into 0-ranked tensor, it change will
hopefully make the operation easier to use for those cases.
2023-09-13 11:33:01 -07:00
Yinying Li
dbe1be9aa4 [mlir][sparse] Migrate tests to use new syntax (#66146)
lvlTypes = [ "compressed" ] to map = (d0) -> (d0 : compressed)
lvlTypes = [ "dense" ] to map = (d0) -> (d0 : dense)
2023-09-13 11:41:25 -04:00
Peiming Liu
64df1c08d0 [sparse] allow unpack op to return any integer type. (#66161) 2023-09-12 17:27:51 -07:00
Mehdi Amini
6f5ebfb987 Fix MLIR integration test that requires ARM SVE to reproduce
Fix-forward for a9f3009758
2023-09-09 15:29:00 -07:00
Mehdi Amini
a9f3009758 Switch MLIR to use the internal LIT shell by default (#65415) 2023-09-09 13:51:27 -07:00