Commit Graph

8402 Commits

Author SHA1 Message Date
Jacques Pienaar a232a48dca [mlir][ods] Skip adding TOC in doc gen when present
Enables adding a TOC in the description to be able to interleave
documentation before and after the TOC.
2021-08-20 07:01:54 -07:00
Denys Shabalin 1631d9a7ea [mlir][linalg] Fix __repr__ implementation in const from opdsl
Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D108369
2021-08-20 12:39:57 +02:00
Vladislav Vinogradov 9775c0c9f0 [mlir] Fix ControlFlowInterfaces implementation for Async dialect
* Add `RegionBranchTerminatorOpInterface` to `YieldOp`.
* Implement `getSuccessorEntryOperands` in `ExecuteOp`.
* Fix `getSuccessorRegions` implementation in `ExecuteOp`.

Reviewed By: ezhulenev

Differential Revision: https://reviews.llvm.org/D108373
2021-08-20 12:14:45 +03:00
Vladislav Vinogradov d1883bc322 [mlir][NFC] Use explicit ::mlir namespace in mlir-tblgen generated code
Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D108376
2021-08-20 11:52:25 +03:00
Rob Suderman 3205ee7e81 [mlir][tosa] Support UInt8 inputs and outputs for tosa.rescale
Tosa rescale can contain uint8 types. Added support for these types
using an unrealized conversion cast. Optimistically it would be better to
use bitcast however it does not support unsigned integers.

Differential Revision: https://reviews.llvm.org/D108427
2021-08-19 18:58:44 -07:00
Morten Borup Petersen 6c1436a9b0 [MLIR][SCF] Parenthesize multiple return types in scf.execute_region asm op
Previously, ExecuteRegionOps with multiple return values would fail a round-trip test due to missing parenthesis around the types.

Differential Revision: https://reviews.llvm.org/D108402
2021-08-19 21:31:51 +01:00
MaheshRavishankar 16ffb283c5 Revert "[mlir][Linalg] Allow all build methods of Structured ops to specify additional attributes."
This reverts commit 95ddc8341a.

Differential Revision: https://reviews.llvm.org/D108396
2021-08-19 11:53:41 -07:00
MaheshRavishankar 95ddc8341a [mlir][Linalg] Allow all build methods of Structured ops to specify additional attributes.
Differential Revision: https://reviews.llvm.org/D108338
2021-08-19 11:14:35 -07:00
Matthias Springer 76a1861816 [mlir][SparseTensor] Split scf.for loop into masked/unmasked parts
Apply the "for loop peeling" pattern from SCF dialect transforms. This pattern splits scf.for loops into full and partial iterations. In the full iteration, all masked loads/stores are canonicalized to unmasked loads/stores.

Differential Revision: https://reviews.llvm.org/D107733
2021-08-19 21:53:11 +09:00
Matthias Springer 8e8b70aa84 [mlir][scf] Simplify affine.min ops after loop peeling
Simplify affine.min ops, enabling various other canonicalizations inside the peeled loop body.

affine.min ops such as:
```
map = affine_map<(d0)[s0, s1] -> (s0, -d0 + s1)>
%r = affine.min #affine.min #map(%iv)[%step, %ub]
```
are rewritten them into (in the case the peeled loop):
```
%r = %step
```

To determine how an affine.min op should be rewritten and to prove its correctness, FlatAffineConstraints is utilized.

Differential Revision: https://reviews.llvm.org/D107222
2021-08-19 17:24:53 +09:00
John Demme 96fbd5cd5e [MLIR] [Python] Add `owner` to `mlir.ir.Block`
Provides a way for python users to access the owning Operation from a Block.
2021-08-19 00:02:09 -07:00
Tobias Gysi 234c4d2362 [mlir][linalg] Set result types in all builders.
Add code to set the result types in all yaml op builders.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D108273
2021-08-19 06:19:12 +00:00
Matthias Springer 08dbed8a57 [mlir][linalg] Canonicalize dim ops of tiled_loop block args
E.g.:
```
%y = ... : tensor<...>
linalg.tiled_loop ... ins(%x = %y : tensor<...>) {
  tensor.dim %x, %c0 : tensor<...>
}
```

is rewritten to:
```
%y = ... : tensor<...>
linalg.tiled_loop ... ins(%x = %y : tensor<...>) {
  tensor.dim %y, %c0 : tensor<...>
}
```

Differential Revision: https://reviews.llvm.org/D108272
2021-08-19 11:24:33 +09:00
Matthias Springer 9329438244 [mlir][linalg] Remove ConstraintsSet class
The same functionality can be implemented with FlatAffineValueConstraints.

Differential Revision: https://reviews.llvm.org/D108179
2021-08-19 10:57:35 +09:00
Matthias Springer c777e51468 [mlir][Analysis][NFC] FlatAffineConstraints: Use BoundType enum in functions
Differential Revision: https://reviews.llvm.org/D108185
2021-08-19 10:33:42 +09:00
Aart Bik d37d72eaf8 [mlir][sparse] use shared util for DimOp generation
This shares more code with existing utilities. Also, to be consistent,
we moved dimension permutation on the DimOp to the tensor lowering phase.
This way, both pre-existing DimOps on sparse tensors (not likely but
possible) as well as compiler generated DimOps are handled consistently.

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D108309
2021-08-18 17:12:32 -07:00
Diego Caballero b7cac864b2 [mlir] Fix typo in SuperVectorizer
NFC.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D108334
2021-08-18 22:55:12 +00:00
Chia-hung Duan 41e5dbe0fa Enables inferring return types for Shape op if possible
Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D102565
2021-08-18 21:36:55 +00:00
Robert Suderman 76c9712196 [mlir][tosa] Fix clamp to restrict only within valid bitwidth range
Its possible for the clamp to have invalid min/max values on its range. To fix
this we validate the range of the min/max and clamp to a valid range.

Reviewed By: NatashaKnk

Differential Revision: https://reviews.llvm.org/D108256
2021-08-18 12:14:01 -07:00
William S. Moses 8c2ff7b69e [MLIR] Correct linkage of lowered globalop
LLVM considers global variables marked as externals to be defined within the module if it is initialized (including to an undef). Other external globals are considered as being defined externally and imported into the current translation unit. Lowering of MLIR Global Ops does not properly propagate undefined initializers, resulting in a global which is expected to be defined within the current TU, not being defined.

Differential Revision: https://reviews.llvm.org/D108252
2021-08-18 11:09:43 -04:00
Butygin ddc3d51d58 [mlir][spirv] Add (InBounds)PtrAccessChain ops
Differential Revision: https://reviews.llvm.org/D108070
2021-08-18 17:59:21 +03:00
Jacques Pienaar b41bfb819d [mlir][ods] Fix packing in OperandOrAttribute
Wrong combiner was used which led to information loss.
2021-08-17 20:55:48 -07:00
Lei Zhang 4c15ad2321 [mlir][linalg] Don't drop existing attributes when creating ops
Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D108219
2021-08-17 15:44:56 -04:00
MaheshRavishankar 836649e040 Allow setting attributes in build method generated by YAML-gen.
Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D108182
2021-08-17 09:09:52 -07:00
Tobias Gysi 583a754248 [mlir][linalg] Remove duplicate methods (NFC).
Remove duplicate methods used to check iterator types.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D108102
2021-08-17 09:06:17 +00:00
John Demme 1689dade42 [MLIR] [Python] Allow 'operation.parent' to return 'None'
This is more Pythonic and better matches the C++ and C APIs.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D108183
2021-08-16 22:38:07 -07:00
John Demme 5821047aac [MLIR] [Python] Fix out-of-tree Windows python bindings
MSVC needs to know where to put the archive (.lib) as well as the runtime
(.dll). If left to the default location, multiple rules to generate the same
file will be produced, creating a Ninja error.

Differential Revision: https://reviews.llvm.org/D108181
2021-08-16 19:18:54 -07:00
Matthias Springer c19c51e357 [mlir][Analysis][NFC] Clean up FlatAffineValueConstraints
* Rename ids to values in FlatAffineValueConstraints.
* Overall cleanup of comments in FlatAffineConstraints and FlatAffineValueConstraints.

Differential Revision: https://reviews.llvm.org/D107947
2021-08-17 10:38:57 +09:00
Matthias Springer 4c4ab673f1 [mlir][Analysis][NFC] Split FlatAffineConstraints class
* Extract "value" functionality of `FlatAffineConstraints` into a new derived `FlatAffineValueConstraints` class. Current users of `FlatAffineConstraints` can use `FlatAffineValueConstraints` without additional code changes, thus NFC.
* `FlatAffineConstraints` no longer associates dimensions with SSA Values. All functionality that requires this, is moved to `FlatAffineValueConstraints`.
* `FlatAffineConstraints` no longer makes assumptions about where Values associated with dimensions are coming from.

Differential Revision: https://reviews.llvm.org/D107725
2021-08-17 10:09:17 +09:00
Geoffrey Martin-Noble e2c97d4484 [MLIR] Add a bitcast method to DenseElementsAttr
This method bitcasts a DenseElementsAttr elementwise to one of the same
shape with a different element type.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D107612
2021-08-16 17:13:35 -07:00
Rob Suderman f328f72e60 [mlir][tosa] Fixed depthwise conv parallel/reduction indices order
Reduction axis should come after all parallel axis to work with vectorization.

Reviewed By: NatashaKnk

Differential Revision: https://reviews.llvm.org/D108005
2021-08-16 14:06:22 -07:00
Robert Suderman 65532ea6dd [mlir][linalg] Clear unused linalg tc operations
These operations are not lowered to from any source dialect and are only
used for redundant tests. Removing these named ops, along with their
associated tests, will make migration to YAML operations much more
convenient.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D107993
2021-08-16 11:55:45 -07:00
Aart Bik 19a906f372 [mlir][sparse][python] make imports more selective
Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D108055
2021-08-16 11:53:29 -07:00
tashuang.zk 2d45e332ba [MLIR][DISC] Revise ParallelLoopTilingPass with inbound_check mode
Expand ParallelLoopTilingPass with an inbound_check mode.

In default mode, the upper bound of the inner loop is from the min op; in
inbound_check mode, the upper bound of the inner loop is the step of the outer
loop and an additional inbound check will be emitted inside of the inner loop.

This was 'FIXME' in the original codes and a typical usage is for GPU backends,
thus the outer loop and inner loop can be mapped to blocks/threads in seperate.

Differential Revision: https://reviews.llvm.org/D105455
2021-08-16 14:02:53 +02:00
Tres Popp 2848f6966e [mlir] Set top-down traversal for LinalgElementwiseOpFusion
The primary pattern for this pass clones many operations from producers
to consumers. Doing this top down prevents duplicated work when a
producer has multiple consumers, if it also is consuming another
linalg.generic.

As an example, a chain of ~2600 generics that are fused into ~70
generics was resulting in 16255 pattern invocations. This took 14
seconds on one machine but takes only 0.3 seconds with top-down
traversal.

Differential Revision: https://reviews.llvm.org/D107818
2021-08-16 09:26:49 +02:00
Stephen Neuendorffer 7776b19eed [MLIR] Move TestDialect to ::test namespace
While the changes are extensive, they basically fall into a few
categories:
1) Moving the TestDialect itself.
2) Updating C++ code in tablegen to explicitly use ::mlir, since it
will be put in a headers that shouldn't expect a 'using'.
3) Updating some generic MLIR Interface definitions to do the same thing.
4) Updating the Tablegen generator in a few places to be explicit about
namespaces
5) Doing the same thing for llvm references, since we no longer pick
up the definitions from mlir/Support/LLVM.h

Differential Revision: https://reviews.llvm.org/D88251
2021-08-14 13:24:41 -07:00
harsh-nod e33f301ec2 [mlir] Add support for moving reductions to outer most dimensions in vector.multi_reduction
The approach for handling reductions in the outer most
dimension follows that for inner most dimensions, outlined
below

First, transpose to move reduction dims, if needed
Convert reduction from n-d to 2-d canonical form
Then, for outer reductions, we emit the appropriate op
(add/mul/min/max/or/and/xor) and combine the results.

Differential Revision: https://reviews.llvm.org/D107675
2021-08-13 12:59:50 -07:00
Lorenzo Chelini e537a3adde [MLIR][Linalg] Fix typo 2021-08-13 18:00:14 +02:00
Adrian Kuegel 3c6f115ffc [mlir] Remove unused header include.
Also adjust BUILD.bazel and remove an unused dependency.

Differential Revision: https://reviews.llvm.org/D108027
2021-08-13 14:23:14 +02:00
Michael Kruse b1de32d6dd [OMPIRBuilder] Clarify CanonicalLoopInfo. NFC.
Add in-source documentation on how CanonicalLoopInfo is intended to be used. In particular, clarify what parts of a CanonicalLoopInfo is considered part of the loop, that those parts must be side-effect free, and that InsertPoints to instructions outside those parts can be expected to be preserved after method calls implementing loop-associated directives.

CanonicalLoopInfo are now invalidated after it does not describe canonical loop anymore and asserts when trying to use it afterwards.

In addition, rename `createXYZWorkshareLoop` to `applyXYZWorkshareLoop` and remove the update location to avoid that the impression that they insert something from scratch at that location where in reality its InsertPoint is ignored. createStaticWorkshareLoop does not return a CanonicalLoopInfo anymore. First, it was not a canonical loop in the clarified sense (containing side-effects in form of calls to the OpenMP runtime). Second, it is ambiguous which of the two possible canonical loops it should actually return. It will not be needed before a feature expected to be introduced in OpenMP 6.0

Also see discussion in D105706.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D107540
2021-08-12 21:02:19 -05:00
natashaknk ba0997ca09 [mlir][tosa] Fix depthwise_conv2D strides/dilation and name
Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D107997
2021-08-12 15:43:41 -07:00
Chia-hung Duan 62df4df41c [mlir-tblgen] Minor Refactor for StaticVerifierFunctionEmitter.
Move StaticVerifierFunctionEmitter to CodeGenHelper.h so that it can be
used for both ODS and DRR.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D106636
2021-08-12 20:53:05 +00:00
Aart Bik 56d607006d [mlir][sparse][python] add an "exhaustive" sparse test using python
Using the python API to easily set up sparse kernels, this test
exhaustively builds, compilers, and runs SpMM for all annotations
on a sparse tensor, making sure every version generates the correct
result. This test also illustrates using the python API to set up
a sparse kernel and sparse compilation.

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D107943
2021-08-12 11:13:04 -07:00
Florian Hahn f999312872
Recommit "[Matrix] Overload stride arg in matrix.columnwise.load/store."
This reverts the revert 28c04794df.

The failing MLIR test that caused the revert should be fixed  in this
version.

Also includes a PPC test fix previously in 1f87c7c478.
2021-08-12 18:31:57 +01:00
Tyler Augustine 3a2ff982d7 Support post-processing Ops in unrolled loop iterations
This can be useful when one needs to know which unrolled iteration an Op belongs to, for example, conveying noalias information among memory-affecting ops in parallel-access loops.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D107789
2021-08-11 23:11:10 +00:00
Benjamin Kramer 35d6e75aba [mlir] Drop LLVM dialect from TestPolynomialApproximation
No longer needed after c1ebefdf77
2021-08-12 00:58:52 +02:00
Mehdi Amini 93e084e7e8 Add missing cmake dep to fix MLIR build with BUILD_SHARED_LIBS=ON (NFC) 2021-08-11 22:51:57 +00:00
Aart Bik a5ae34afaa [mlir][linalg] fixed typo
Differential Revision: https://reviews.llvm.org/D107915
2021-08-11 11:59:15 -07:00
Rob Suderman 7de439b2be [mlir][tosa] Migrate tosa to more efficient linalg.conv
Existing linalg.conv2d is not well optimized for performance. Changed to a
version that is more aligned for optimziation. Include the corresponding
transposes to use this optimized version.

This also splits the conv and depthwise conv into separate implementations
to avoid overly complex lowerings.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D107504
2021-08-11 11:05:12 -07:00
Benjamin Kramer c1ebefdf77 [mlir] Make polynomial approximation emit std instead of LLVM ops
This is a bit cleaner and removes issues with 2d vectors. It also has a
big impact on constant folding, hence the test changes.

Differential Revision: https://reviews.llvm.org/D107896
2021-08-11 16:37:21 +02:00