Commit Graph

12878 Commits

Author SHA1 Message Date
Jeff Niu a5c46bf952 [mlir] Allow DenseElementsAttr to use any shaped type
This patch allows the type of DenseElementsAttr to be any shaped type.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D135002
2022-09-30 23:25:14 -07:00
wren romano 089868ce16 [mlir][sparse] Improving error messages for MLIR_SPARSETENSOR_FATAL
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D135000
2022-09-30 17:38:32 -07:00
River Riddle c692a11e69 [mlir] Flip Async/GPU/MemRef/OpenACC/OpenMP/PDL dialects to prefixed
This flips all of the remaining dialects to prefixed except for linalg, which
will be done in a followup.

Differential Revision: https://reviews.llvm.org/D134995
2022-09-30 16:55:30 -07:00
Jeff Niu 0d21596c1d [mlir][ods] Allow references to the self type
The self type always "bound" since it is provided to the attribute
parser hook. Allow custom directives to reference it.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D134997
2022-09-30 16:34:01 -07:00
River Riddle 4fb4e12bab [mlir:OpenMP][NFC] Update OpenMP API to use prefixed accessors
This doesn't flip the switch for prefix generation yet, that'll be
done in a followup.
2022-09-30 15:27:11 -07:00
River Riddle f9806b3e3e [mlir:OpenACC][NFC] Update OpenACC API to use prefixed accessors
This doesn't flip the switch for prefix generation yet, that'll be
done in a followup.
2022-09-30 15:27:10 -07:00
River Riddle 310c3ee472 [mlir:PDL][NFC] Update PDL API to use prefixed accessors
This doesn't flip the switch for prefix generation yet, that'll be
done in a followup.
2022-09-30 15:27:10 -07:00
River Riddle 10c04f4641 [mlir:GPU][NFC] Update GPU API to use prefixed accessors
This doesn't flip the switch for prefix generation yet, that'll be
done in a followup.
2022-09-30 15:27:10 -07:00
River Riddle a5aa783685 [mlir:Async][NFC] Update Async API to use prefixed accessors
This doesn't flip the switch for prefix generation yet, that'll be
done in a followup.
2022-09-30 15:27:10 -07:00
wren romano b3c5da73b7 [mlir][sparse] Address style nit in documentation
Reviewed By: aartbik, Peiming

Differential Revision: https://reviews.llvm.org/D134986
2022-09-30 15:22:43 -07:00
Kazu Hirata e898be2f6e [mlir] Fix warnings
This patch fixes:

  mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp:1348:31: error: comparison
  of integers of different signs: 'size_t' (aka 'unsigned long') and
  'int64_t' (aka 'long') [-Werror,-Wsign-compare]

  mlir/lib/ExecutionEngine/SparseTensor/File.cpp:110:3: error: default
  label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]
2022-09-30 15:00:56 -07:00
Peiming Liu 00ad065548 [mlir][sparse] Add rewriting rules for concatente using foreach operator.
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D134895
2022-09-30 21:56:55 +00:00
Peiming Liu 550288cbc3 [mlir][sparse] Add new utility class to help generates loop structures over sparse tensors; Implement foreach operator.
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D134782
2022-09-30 21:42:42 +00:00
wren romano 0011c0a159 [mlir][sparse] Renaming x-macros for better hygiene
Now that mlir_sparsetensor_utils is a public library, this differential renames the x-macros to help avoid namespace pollution issues.

Reviewed By: aartbik, Peiming

Differential Revision: https://reviews.llvm.org/D134988
2022-09-30 14:04:58 -07:00
Lei Zhang 9e8e4779a2 [mlir][vector] Fix double rank reducing folding bug
In https://reviews.llvm.org/D133883, we changed the
`FoldExtractSliceIntoTransferRead` pattern from requiring
full identity map to minor identity map. This effectively
allows rank reducing `vector.transfer_read` ops. However,
the logic for checking `tensor.extract_slice` rank reducing
still looks at the vector rank, which now could be smaller
than the `tensor.extract_slice`'s output tensor rank.
It ends up we can have incorrect index cacluation after
folding due to this double rank reducing behavior.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D134984
2022-09-30 16:50:48 -04:00
wren romano 97bd83b51f [mlir][sparse] SparseTensorUtils post-refactoring cleanup
This differential corrects a few minor rebasing errors from the recent slew of differentials for factoring out the mlir_sparsetensor_utils library.

Reviewed By: aartbik, Peiming

Differential Revision: https://reviews.llvm.org/D134985
2022-09-30 13:29:46 -07:00
wren romano 1d4d1c99c5 [mlir][sparse] Factoring out predicates on DimLevelTypes
This way the predicates can be reused elsewhere, and can more easily be kept in sync with changes to the enum.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D134926
2022-09-30 11:15:34 -07:00
Quentin Colombet d831568171 [mlir][MemRef] Simplify extract_strided_metadata(collapse_shape)
The new pattern gets rid of the collapse_shape operation while
materializing its effects on the sizes, and the strides of the base
object.

In other words, this simplification replaces:

```
baseBuffer, offset, sizes, strides =
    extract_strided_metadata(collapse_shape(memref))
```

With

```
baseBuffer, offset, baseSizes, baseStrides =
    extract_strided_metadata(memref)
for reassDim in {0 .. collapseRank - 1}
  sizes#reassDim = product(baseSizes#i for i in group[reassDim])
  strides#reassDim = baseStrides[group[reassDim].back()]
```

Note: baseBuffer and offset are unaffected by the collapse_shape
operation.

Differential Revision: https://reviews.llvm.org/D134826
2022-09-30 16:54:56 +00:00
Aart Bik 94e4928bd3 [mlir][sparse] minor edit in doc, removed TAB from test
Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D134924
2022-09-30 09:42:36 -07:00
Oleg Shyshkov c54bc8bd07 [mlir][linalg] Use getIteratorTypeArray instead of raw iterator_type attribute.
Summary:
Also modify helper methods to take StringRefs instread of Attributes. It makes
the code cleaner and will help with future migration from StringRef to
utils::IteratorType ([RFC](https://discourse.llvm.org/t/rfc-enumattr-for-iterator-types-in-linalg/64535)).

Differential Revision: https://reviews.llvm.org/D134888
2022-09-30 16:03:33 +00:00
Nicolas Vasilache 435debea69 [mlir][test] NFC - Fix some worst offenders "capture by SSA name" tests
Many tests still depend on specific names of SSA values (!!).
This commit is a best effort cleanup that will set the stage for adding some pretty SSA result names.
2022-09-30 08:24:13 -07:00
Alex Zinenko 8975fb0b26 [mlir] fix DiagnosedSilenceableFailure::takeDiagnostics
This function was returning an rvalue reference to an object that was
also cleared via RAII when the function returned, making it always
return an empty object. Make it accept the mutable reference to the
object instead to avoid this dangerous behavior.

Reviewed By: guraypp

Differential Revision: https://reviews.llvm.org/D134948
2022-09-30 11:34:48 +00:00
Adrian Kuegel 67bcf9825a [mlir][SCF] Apply ClangTidyPerformance finding (NFC) 2022-09-30 12:47:32 +02:00
Oleg Shyshkov 1227b8ab54 [mlir] Rename getTied* methods to getMatching* in LinalgInterface.
Summary:
As mentioned in the comment to https://reviews.llvm.org/D134444, the term `tied`
is a misnomer in this context and `matching` sounds much better.

Differential Revision: https://reviews.llvm.org/D134534
2022-09-30 10:05:45 +00:00
Adrian Kuegel fa79dff8bc [mlir][Linalg] Reland Add ReduceOp to Linalg structured ops.
This op will allow to model (variadic) reductions with this special op
instead of using GenericOp.

This reverts commit 535fd753ef.
Additional fix: implement a getLibraryName method.
2022-09-30 08:42:34 +02:00
Nirvedh Meshram d6de6dde82 [mlir][spirv] Handle dynamic/static cases differntly for kernel capability
Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D134908
2022-09-29 19:34:42 -07:00
wren romano c8944c9d4c [mlir][sparse] Fixing case coverage warning
Followup to D133835 for fixing the warning on LLVM's Windows buildbot

Reviewed By: aartbik, Peiming, stella.stamenova

Differential Revision: https://reviews.llvm.org/D134925
2022-09-29 18:20:36 -07:00
Peiming Liu 11069cbcb4 [mlir][sparse] refactoring: split translateIndices.
TranslateIndicesArray take an array of SSA value and convert them into another array of SSA values based on reassociation. Which makes it easier to be reused by `foreach` operator (as the indices array are given as an array of SSA values).

Reviewed By: aartbik, bixia

Differential Revision: https://reviews.llvm.org/D134918
2022-09-29 23:59:39 +00:00
bixia1 1c835b5a8e [mlir][sparse] Allow the push_back operator to skip capacity check and reallocation.
Add UnitAttr `inbounds` for this purpose.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D134913
2022-09-29 16:38:06 -07:00
Aart Bik 0bfaa301e2 [mlir][sparse] implement singleton dimension level type
This is a first step towards fully implementing the new dimension
level types and properties, illustrating with a fully functional
sorted COO of any dimension. Note that the sparsification part is
pretty complete. The required parts in the runtime support library
have been kept to a minimum, to avoid huge conflicts with Wren's
ongoing refactoring. The missing parts will be filled in later.

Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D134096
2022-09-29 16:25:07 -07:00
Jeff Niu 5e82120e68 [mlir] Use `interleave` in `printOperands` (NFC)
Instead of reimplementing it.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D134904
2022-09-29 15:58:37 -07:00
Jeff Niu 3840e960ba [mlir] Add `OpAsmPrinter::printOptionalLocationSpecifier`
This is the corresponding method to
`OpAsmParser::parseOptionalLocationSpecifier` that prints a location
`loc(...)` based on the op printing flags. Together, these two functions
allow propagating user-level location info outside of their usual spots.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D134910
2022-09-29 15:58:10 -07:00
wren romano 68609598e4 [mlir][sparse] Improve sparse_tensor::detail::readCOOValue template
This is a followup to the refactoring of D133462, D133830, D133831, and D133833.

Depends On D133833

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133836
2022-09-29 15:26:29 -07:00
wren romano c42ecce7b9 [mlir][sparse] optimizing permutation validity check in toMLIRSparseTensor
The previous sorting-based check was O(n*log n). The new implementation is O(n).

This is a followup to the refactoring of D133462, D133830, D133831, and D133833.

Depends On D133833

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133838
2022-09-29 15:08:46 -07:00
bixia1 654bbbde55 [mlir][sparse] Move the implementation of sparse_tensor.push_back to the buffer rewriter.
Reviewed By: aartbik, Peiming

Differential Revision: https://reviews.llvm.org/D134777
2022-09-29 15:06:00 -07:00
wren romano ac741889c1 [mlir][sparse] Adding isSorted bit to SparseTensorCOO
This is a followup to the refactoring of D133462, D133830, D133831, and D133833.

Depends On D133833

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133839
2022-09-29 15:02:17 -07:00
wren romano 4792b8ae86 [mlir][sparse] Cleaning up SparseTensorFile::readMMEHeader
This is a followup to the refactoring of D133462, D133830, D133831, and D133833.

Depends On D133833

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133837
2022-09-29 15:00:50 -07:00
wren romano c8177f845b [mlir][sparse] Factoring out SparseTensorFile::canReadAs predicate
This is a followup to the refactoring of D133462, D133830, D133831, and D133833.

Depends On D133833

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133835
2022-09-29 14:46:45 -07:00
wren romano 164b66f796 [mlir][sparse] refactoring SparseTensorUtils: (4 of 4) documentation
Previously, the SparseTensorUtils.cpp library contained a C++ core implementation, but hid it in an anonymous namespace and only exposed a C-API for accessing it. Now we are factoring out that C++ core into a standalone C++ library so that it can be used directly by downstream clients (per request of one such client). This refactoring has been decomposed into a stack of differentials in order to simplify the code review process, however the full stack of changes should be considered together.

* D133462: Part 1: split one file into several
* D133830: Part 2: Reorder chunks within files
* D133831: Part 3: General code cleanup
* (this): Part 4: Update documentation

This part updates existing documentation, adds new documentation, and reflows the test for some existing documentation.

Depends On D133831

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133833
2022-09-29 14:45:36 -07:00
wren romano 329f2f103a [mlir][sparse] refactoring SparseTensorUtils: (3 of 4) code-cleanup
Previously, the SparseTensorUtils.cpp library contained a C++ core implementation, but hid it in an anonymous namespace and only exposed a C-API for accessing it. Now we are factoring out that C++ core into a standalone C++ library so that it can be used directly by downstream clients (per request of one such client). This refactoring has been decomposed into a stack of differentials in order to simplify the code review process, however the full stack of changes should be considered together.

* D133462: Part 1: split one file into several
* D133830: Part 2: Reorder chunks within files
* (this): Part 3: General code cleanup
* D133833: Part 4: Update documentation

This part performs some general code cleanup including:
* making more things `const`, especially for the targets of pointers
* using preincrement wherever possible ([[ https://llvm.org/docs/CodingStandards.html#prefer-preincrement | per LLVM style guide ]])
* adding messages to most `assert` statments.
* moving argument casting from the core function/method definitions to the CPP wrappers

Depends On D133830

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133831
2022-09-29 14:44:07 -07:00
wren romano 4c9ee145c0 [mlir][sparse] refactoring SparseTensorUtils: (2 of 4) reordering
Previously, the SparseTensorUtils.cpp library contained a C++ core implementation, but hid it in an anonymous namespace and only exposed a C-API for accessing it. Now we are factoring out that C++ core into a standalone C++ library so that it can be used directly by downstream clients (per request of one such client). This refactoring has been decomposed into a stack of differentials in order to simplify the code review process, however the full stack of changes should be considered together.

* D133462: Part 1: split one file into several
* (this): Part 2: Reorder chunks within files
* D133831: Part 3: General code cleanup
* D133833: Part 4: Update documentation

This part moves chunks of code within files, but again aims to make no other changes. Many of these movements are part of a stylistic shift to reorder the components of class definitions as follows: data members, ctors/factories, getters, other public methods, private methods.

Depends On D133462

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133830
2022-09-29 14:42:07 -07:00
wren romano 0fca5c5f45 [mlir][sparse] refactoring SparseTensorUtils: (1 of 4) file-splitting
Previously, the SparseTensorUtils.cpp library contained a C++ core implementation, but hid it in an anonymous namespace and only exposed a C-API for accessing it. Now we are factoring out that C++ core into a standalone C++ library so that it can be used directly by downstream clients (per request of one such client). This refactoring has been decomposed into a stack of differentials in order to simplify the code review process, however the full stack of changes should be considered together.

* (this): Part 1: split one file into several
* D133830: Part 2: Reorder chunks within files
* D133831: Part 3: General code cleanup
* D133833: Part 4: Update documentation

This part aims to make no changes other than the 1:N file splitting, and things which are forced to accompany that change.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133462
2022-09-29 14:35:27 -07:00
Aart Bik bfbf3bcb37 [mlir][sparse] fix build breakage due to Arith name change
Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D134899
2022-09-29 12:12:43 -07:00
bixia1 062e515b70 [mlir][sparse] Add rewrite rule for the sort operator.
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 11:38:19 -07:00
Stella Stamenova 535fd753ef Revert "[mlir][Linalg] Add ReduceOp to Linalg structured ops."
This reverts commit d02233f0da.

This commit the Windows mlir buildbot: https://lab.llvm.org/buildbot/#/builders/13/builds/26413
2022-09-29 10:23:54 -07:00
Mahesh Ravishankar 0d5cb90f6c [mlir][scf] Simplify the logic for `replaceLoopWithNewYields` for perfectly nested loops.
Based on discussion in https://reviews.llvm.org/D134411, instead of
first modifying the inner most loop first followed by modifying the
outer loops from inside out, this patch restructures the logic to
start the modification from the outer most loop.

Differential Revision: https://reviews.llvm.org/D134832
2022-09-29 16:52:02 +00:00
Maksim Levental e753bc8745 [mlir][Affine] Move/expose hasNoInterveningEffect
Expose [[ https://github.com/llvm/llvm-project/blob/main/mlir/lib/Dialect/Affine/Utils/Utils.cpp#L661 | Dialect/Affine/Utils/Utils.cpp#hasNoInterveningEffect ]] for downstream use (particular use case is a lazy implementation of [[ https://github.com/llvm/llvm-project/blob/main/mlir/lib/Dialect/Affine/Utils/Utils.cpp#L845 | forwardStoreToLoad ]] in CIRCT). This exposes hasNoInterveningEffect and instantiates for the necessary types.

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D134374
2022-09-29 11:10:17 -05:00
Jakub Kuderski abc362a107 [mlir][arith] Change dialect name from Arithmetic to Arith
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-29 11:23:28 -04:00
Adrian Kuegel d02233f0da [mlir][Linalg] Add ReduceOp to Linalg structured ops.
This will allow to model (variadic) reductions with this special op instead of
using GenericOp.

RFC: https://discourse.llvm.org/t/rfc-primitive-ops-add-mapop-reductionop-transposeop-broadcastop-to-linalg/64184
2022-09-29 16:23:12 +02:00
Alex Zinenko 93b7bdcda7 [mlir] fix formatting in markdown 2022-09-29 14:10:36 +00:00