Commit Graph

8116 Commits

Author SHA1 Message Date
Nicolas Vasilache df538fdaa9 [mlir][affine] Add single result affine.min/max -> affine.apply canonicalization.
Differential Revision: https://reviews.llvm.org/D106014
2021-07-14 20:38:06 +00:00
Nicolas Vasilache 7b47de774f [mlir] NFC - Add AffineMap::replace variant with dim/symbol inference 2021-07-14 20:29:12 +00:00
Matthias Springer b70dde522d [mlir][linalg] Fix typo in ExtractSliceOfPadTensorSwapPattern
Differential Revision: https://reviews.llvm.org/D105607
2021-07-14 22:30:32 +09:00
Butygin a36e9ee09d [mlir][SCF] populateSCFStructuralTypeConversionsAndLegality WhileOp support
Differential Revision: https://reviews.llvm.org/D105923
2021-07-14 12:43:04 +03:00
Geoffrey Martin-Noble 9955c652ea [NFC][MLIR][std] Clean up ArithmeticCastOps
The documentation on these was out of sync with the implementation. Also
the declaration of inputs was repeated when it is already part of the
ArithmeticCastOp definition.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D105934
2021-07-13 15:18:45 -07:00
MaheshRavishankar f2b5e438aa [mlir][Tensor] Implement `reifyReturnTypeShapesPerResultDim` for `tensor.insert_slice`.
Differential Revision: https://reviews.llvm.org/D105852
2021-07-13 14:53:29 -07:00
Aart Bik 123e8dfcf8 [mlir][sparse] add support for std unary operations
Adds zero-preserving unary operators from std. Also adds xor.
Performs minor refactoring to remove "zero" node, and pushed
the irregular logic for negi (not support in std) into one place.

Reviewed By: gussmith23

Differential Revision: https://reviews.llvm.org/D105928
2021-07-13 14:51:13 -07:00
Adam Paszke 8a2720d81e Add more types to the LLVM dialect C API
This includes:
- void type
- array types
- function types
- literal (unnamed) struct types

Reviewed By: jpienaar, ftynse

Differential Revision: https://reviews.llvm.org/D105908
2021-07-13 14:35:50 -07:00
thomasraoux 6296e10972 [mlir][Vector] Remove Vector TupleOp as it is unused
TupleOp is not used anymore after recent refactoring.

Differential Revision: https://reviews.llvm.org/D105924
2021-07-13 12:39:12 -07:00
thomasraoux ae4cea38f1 [mlir] Add support for tensor.extract to comprehensive bufferization
Differential Revision: https://reviews.llvm.org/D105870
2021-07-13 09:54:46 -07:00
Guillaume Chatelet 2c47b8847e Revert "[llvm] Add enum iteration to Sequence"
This reverts commit a006af5d6e.
2021-07-13 16:44:42 +00:00
Nicolas Vasilache 68ae8bacfc [mlir][Linalg] Properly specify Linalg attribute.
This fixes undefined reference introduced by https://reviews.llvm.org/D105859

Differential Revision: https://reviews.llvm.org/D105897
2021-07-13 16:33:33 +00:00
Guillaume Chatelet a006af5d6e [llvm] Add enum iteration to Sequence
This patch allows iterating typed enum via the ADT/Sequence utility.

Differential Revision: https://reviews.llvm.org/D103900
2021-07-13 16:22:19 +00:00
Aart Bik 7039dfc6dd [mlir][memref] adjust integration tests to new lowering passes
these tests run under the emulator and thus were overlooked

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D105855
2021-07-13 09:14:41 -07:00
Tres Popp 32627f4ab4 [mlir] Handle unused variable when assertions are disabled. 2021-07-13 17:31:12 +02:00
Frederik Gossen 9c90725eae [MLIR] Fix documentation of the `ExecutionEngine` in the toy tutorial example
Differential Revision: https://reviews.llvm.org/D105813
2021-07-13 13:23:43 +02:00
Nicolas Vasilache af55335924 [mlir][Linalg] Better support for bufferizing non-tensor results.
Clean up corner cases related to elemental tensor / buffer type return values that would previously fail.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D105857
2021-07-13 10:27:40 +00:00
Nicolas Vasilache e312fc49ae [mlir][Linalg] Add layout specification support to bufferization.
Previously, linalg bufferization always had to be conservative at function boundaries and assume the most dynamic strided memref layout.
This revision introduce the mechanism to specify a  linalg.buffer_layout function argument attribute that carries an affine map used to set a less pessimistic layout.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D105859
2021-07-13 10:22:18 +00:00
Aart Bik 45b3cfe843 [mlir][sparse] add support for AND and OR operations
Integral AND and OR follow the simple conjunction and disjuction rules
for lattice building. This revision also completes some of the Merge
refactoring by moving the remainder parts that are merger specific from
sparsification into utils files.

Reviewed By: gussmith23

Differential Revision: https://reviews.llvm.org/D105851
2021-07-12 17:47:18 -07:00
Hanhan Wang 50529affcd [mlir][Linalg] Add 3D pooling named ops to Linalg.
Reviewed By: gysit, hanchung

Differential Revision: https://reviews.llvm.org/D105329
2021-07-12 17:26:02 -07:00
Rob Suderman f2832c2295 [mlir][tosa] Added shape propagation for TOSA pool operations.
Pool operations perform the same shape propagation. Included the shape
propagation and tests for these avg_pool2d and max_pool2d.

Differential Revision: https://reviews.llvm.org/D105665
2021-07-12 15:40:49 -07:00
Aart Bik 622eb169f6 [mlir][sparse] add restrictive versions of division support
Right now, we only accept x/c with nonzero c, since this
conceptually can be treated as a x*(1/c) conjunction for both
FP and INT as far as lattice computations go. The codegen
keeps the division though to preserve precise semantics.

See discussion:
https://llvm.discourse.group/t/sparse-tensors-in-mlir/3389/28

Reviewed By: gussmith23

Differential Revision: https://reviews.llvm.org/D105731
2021-07-12 14:59:48 -07:00
Gus Smith 40843347b3 [mlir][sparse] Add Merger unit tests (with gcc5 build fix)
This is a fix of https://reviews.llvm.org/D104956, which broke the gcc5 build.

We opt to use unit tests rather than check tests as the lattice/merger code is a small C++ component with a well-defined API. Testing this API via check tests would be far less direct and readable. In addition, as the check tests will only be able to test the API indirectly, the tests may break based on unrelated changes; e.g. changes in linalg.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D105828
2021-07-12 20:36:10 +00:00
Nikita Popov 6ac32872ee [Attributes] Replace doesAttrKindHaveArgument() (NFC)
This is now the same as isIntAttrKind(), so use that instead, as
it does not require manual maintenance. The naming is also more
accurate in that both int and type attributes have an argument,
but this method was only targeting int attributes.

I initially wanted to tighten the AttrBuilder assertion, but we
have some in-tree uses that would violate it.
2021-07-12 21:57:26 +02:00
Rob Suderman 5a4e776010 [mlir][tosa] Added more shape inference for tosa ops
Added shape inference for:
- scatter
- gather
- transpose
- slice
- pad
- concat
- reduction operations

Also updated reshape for more aggressive shape inference.

Differential Revision: https://reviews.llvm.org/D105383
2021-07-12 10:04:49 -07:00
Frederik Gossen ed1f149b54 [MLIR][StandardToLLVM] Move `copyUnrankedDescriptors` to pattern
Make the function `copyUnrankedDescriptors` accessible in
`ConvertToLLVMPattern`.

Differential Revision: https://reviews.llvm.org/D105810
2021-07-12 15:35:07 +02:00
Tobias Gysi b4e843ba3a [mlir][linalg][python] Add auto-generated file warning (NFC).
Annotate LinalgNamedStructuredOps.yaml with a comment stating the file is auto-generated and should not be edited manually.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D105809
2021-07-12 12:54:14 +00:00
Nicolas Vasilache 6b1668397f [mlir][Linalg] Improve comprehensive bufferization for scf.yield.
Previously, comprehensive bufferization of scf.yield did not have enough information
to detect whether an enclosing scf::for bbargs would bufferize to a buffer equivalent
to that of the matching scf::yield operand.
As a consequence a separate sanity check step would be required to determine whether
bufferization occured properly.
This late check would miss the case of calling a function in an loop.

Instead, we now pass and update aliasInfo during bufferization and it is possible to
imrpove bufferization of scf::yield and drop that post-pass check.

Add an example use case that was failing previously.
This slightly modifies the error conditions, which are also updated as part of this
revision.

Differential Revision: https://reviews.llvm.org/D105803
2021-07-12 10:36:25 +00:00
Alex Zinenko 26e59cc19f [mlir] factor math-to-llvm out of standard-to-llvm
After the Math has been split out of the Standard dialect, the
conversion to the LLVM dialect remained as a huge monolithic pass.
This is undesirable for the same complexity management reasons as having
a huge Standard dialect itself, and is even more confusing given the
existence of a separate dialect. Extract the conversion of the Math
dialect operations to LLVM into a separate library and a separate
conversion pass.

Reviewed By: silvas

Differential Revision: https://reviews.llvm.org/D105702
2021-07-12 11:09:42 +02:00
Jacques Pienaar 51cbe4e587 [mlir] Fix broadcasting check with 1 values
The trait was inconsistent with the other broadcasting logic here. And
also fix printing here to use ? rather than -1 in the error.

Differential Revision: https://reviews.llvm.org/D105748
2021-07-11 20:41:33 -07:00
Itai Zukerman ebbe149a6f [mlir] Gated calls to getAsm{Result,BlockArgument}Names on whether printing ops in generic form.
Depends On D105300

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D105301
2021-07-10 17:19:37 +00:00
Itai Zukerman 2c0f17982f [mlir] Added OpPrintingFlags to AsmState and SSANameState.
This enables checking the printing flags when formatting names
in SSANameState.

Depends On D105299

Reviewed By: mehdi_amini, bondhugula

Differential Revision: https://reviews.llvm.org/D105300
2021-07-10 16:40:00 +00:00
Itai Zukerman f4f11ee4a7 [mlir][NFC] Switched `interfaces` to a private member of SSANameState.
`interfaces` is passed through to the `numberValuesIn*` functions with exactly
the same value as when SSANameState is constructed.  This just seems cleaner.

Also, a dependent PR adds `printerFlags` which follows similar code paths.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D105299
2021-07-10 16:40:00 +00:00
Uday Bondhugula fc01fafa3e [MLIR][GPU][NFC] Fix documentation for wmma matrix load/store ops
Fix/improve documentation for wmma load/store matrix ops. Fix some
broken and stale sentences.

Differential Revision: https://reviews.llvm.org/D105678
2021-07-10 05:19:06 +05:30
Alex Zinenko c282d55a38 [mlir] add support for reductions in OpenMP WsLoopOp
Use a modeling similar to SCF ParallelOp to support arbitrary parallel
reductions. The two main differences are: (1) reductions are named and declared
beforehand similarly to functions using a special op that provides the neutral
element, the reduction code and optionally the atomic reduction code; (2)
reductions go through memory instead because this is closer to the OpenMP
semantics.

See https://llvm.discourse.group/t/rfc-openmp-reduction-support/3367.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D105358
2021-07-09 17:54:20 +02:00
Alex Zinenko d4df3825bd [mlir] don't drop undef initializers in translation to LLVM IR
LLVM IR allows globals with external linkage to have initializers, including
undef. The translation was incorrectly using undef as a indicator that the
initializer should be ignored in translation, leading to the impossibility to
create an external global with an explicit undef initializer. Fix this and use
nullptr as a marker instead.

Reviewed By: wsmoses

Differential Revision: https://reviews.llvm.org/D105631
2021-07-09 17:52:43 +02:00
Alex Zinenko 75e5f0aac9 [mlir] factor memref-to-llvm lowering out of std-to-llvm
After the MemRef has been split out of the Standard dialect, the
conversion to the LLVM dialect remained as a huge monolithic pass.
This is undesirable for the same complexity management reasons as having
a huge Standard dialect itself, and is even more confusing given the
existence of a separate dialect. Extract the conversion of the MemRef
dialect operations to LLVM into a separate library and a separate
conversion pass.

Reviewed By: herhut, silvas

Differential Revision: https://reviews.llvm.org/D105625
2021-07-09 14:49:52 +02:00
Mehdi Amini 38451fa178 Revert "[mlir][sparse] Add Merger unit tests"
This reverts commit 0d0cff3ace.

The build is broken with GCC 5.4
2021-07-09 01:43:19 +00:00
Chia-hung Duan 70eb3bfff0 [mlir-reduce] Fix the grammer in the doc
Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D105623
2021-07-09 08:01:35 +08:00
Gus Smith 0d0cff3ace [mlir][sparse] Add Merger unit tests
We opt to use unit tests rather than check tests as the lattice/merger code is a small C++ component with a well-defined API. Testing this API via check tests would be far less direct and readable. In addition, as the check tests will only be able to test the API indirectly, the tests may break based on unrelated changes; e.g. changes in linalg.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D104956
2021-07-08 23:10:33 +00:00
Yi Zhang 7c35aae35b Mark TensorDialect legal and PadTensor op illegal
`GeneralizePadTensorOpPattern` might generate `tensor.dim` op so the
TensorDialect should be marked legal. This pattern should also
transform all `linalg.pad_tensor` ops so mark those as illegal. Those
changes are missed from a previous change in
https://reviews.llvm.org/D105293

Reviewed By: silvas

Differential Revision: https://reviews.llvm.org/D105642
2021-07-08 15:02:22 -07:00
David Blaikie 1def2579e1 PR51018: Remove explicit conversions from SmallString to StringRef to future-proof against C++23
C++23 will make these conversions ambiguous - so fix them to make the
codebase forward-compatible with C++23 (& a follow-up change I've made
will make this ambiguous/invalid even in <C++23 so we don't regress
this & it generally improves the code anyway)
2021-07-08 13:37:57 -07:00
Nicolas Vasilache 4747e1b83b [mlir][Linalg] Fix tensor.extract_slice(linalg.init_tensor) canonicalization for rank-reducing extract
Differential Revision: https://reviews.llvm.org/D105636
2021-07-08 18:13:51 +00:00
Aart Bik 8cf60e61e7 [mlir][sparse] updated setter/getter comments
For the getters, it is bad practice to keep the reference
around for too long, as explained in the new comment

Reviewed By: gussmith23

Differential Revision: https://reviews.llvm.org/D105599
2021-07-08 09:36:22 -07:00
Markus Böck 3e6d2cbf26 [mlir] Fully qualify types and expressions in Interfaces
This patch adds full qualification to the types and function calls used inside of (Static)InterfaceMethod in OpInterfaces. Without this patch using many of these interfaces in a downstream project yields compiler errors as the types and default implementations are mostly copied verbatim. Without then putting using namespace mlir; in the header file of the implementations of those interfaces, compilation is impossible.

Using fully qualified lookup fixes this issue.

Differential Revision: https://reviews.llvm.org/D105619
2021-07-08 16:44:16 +02:00
Chia-hung Duan ba913b8da5 [mlir-reduce] Fix the memory leak and recycle unused modules.
Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D105416
2021-07-08 20:03:47 +08:00
Nicolas Vasilache 31f80393bc Revert "[mlir][MemRef] Fix DimOp folding of OffsetSizeAndStrideInterface."
This reverts commit 6c0fd4db79.

This simple implementation is unfortunately not extensible and needs to be reverted.
The extensible way should be to extend https://reviews.llvm.org/D104321.
2021-07-08 10:09:00 +00:00
Tobias Gysi abfa950d86 [mlir][linalg][python] Add exp and log to the OpDSL.
Introduce the exp and log function in OpDSL. Add the soft plus operator to test the emitted IR in Python and C++.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D105420
2021-07-08 08:48:23 +00:00
Tobias Gysi 84354b2ab2 [mlir][linalg] Remove GenericOpBase.
Remove the GenericOpBase class formerly used to factor out common logic shared be GenericOp and IndexedGenericOp. After removing IndexedGenericOp, the base class is not used anymore.

Differential Revision: https://reviews.llvm.org/D105307
2021-07-08 08:35:28 +00:00
Nicolas Vasilache 6c0fd4db79 [mlir][MemRef] Fix DimOp folding of OffsetSizeAndStrideInterface.
This addresses the issue reported in

https://llvm.discourse.group/t/rank-reducing-memref-subview-offsetsizeandstrideopinterface-interface-issues/3805

Differential Revision: https://reviews.llvm.org/D105558
2021-07-08 08:30:24 +00:00