Commit Graph

6286 Commits

Author SHA1 Message Date
Jacques Pienaar e08a991f56 [mlir][tosa] Enable decomposing Conv2D also where 1 input dim is dynamic
Restricted to just 1 dynamic input dim as that worked all the way through to
codegen.

Differential Revision: https://reviews.llvm.org/D129334
2022-07-08 10:57:04 -07:00
Nicolas Vasilache 69c8319e76 [mlir][Transform] Fix isDefiniteFailure helper
This newly added helper was returning definiteFailure even in the case of silenceableFailure.

Differential Revision: https://reviews.llvm.org/D129347
2022-07-08 00:39:42 -07:00
Mogball c20a581a8d [mlir] Delete ForwardDataFlowAnalysis
With SCCP and integer range analysis ported to the new framework, this old framework is redundant. Delete it.

Depends on D128866

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D128867
2022-07-07 21:08:27 -07:00
Mogball ab701975e7 [mlir] Swap integer range inference to the new framework
Integer range inference has been swapped to the new framework. The integer value range lattices automatically updates the corresponding constant value on update.

Depends on D127173

Reviewed By: krzysz00, rriddle

Differential Revision: https://reviews.llvm.org/D128866
2022-07-07 20:28:13 -07:00
lewuathe f27deeee79 [mlir][complex] Lower complex.angle to libm
complex.angle corresponds to arg function in libm. We can lower complex.angle to arg and argf.

Reviewed By: pifon2a

Differential Revision: https://reviews.llvm.org/D129341
2022-07-08 04:39:23 +02:00
lewuathe eaba6e0b5c [mlir][complex] Convert complex.abs to libm
Convert complex.abs to libm library

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D127476
2022-07-08 09:55:51 +09:00
Aart Bik d926b3307e [mlir] add complex type to getZeroAttr
Fixes issue encountered with <sparse> complex constant
https://github.com/llvm/llvm-project/issues/56428

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D129325
2022-07-07 16:58:59 -07:00
Mogball d80c271c8a [mlir] An implementation of dense data-flow analysis
This patch introduces an implementation of dense data-flow analysis. Dense
data-flow analysis attaches a lattice before and after the execution of every
operation. The lattice state is propagated across operations by a user-defined
transfer function. The state is joined across control-flow and callgraph edges.

Thge patch provides an example pass that uses both a dense and a sparse analysis
together.

Depends on D127139

Reviewed By: rriddle, phisiart

Differential Revision: https://reviews.llvm.org/D127173
2022-07-07 15:12:46 -07:00
Krzysztof Drewniak db590549a9 [mlir][AMDGPU] Use the correct values for OOB_SELECT on gfx10
Differential Revision: https://reviews.llvm.org/D129320
2022-07-07 21:23:38 +00:00
River Riddle ed2fb1736a [mlir:LSP] Add support for MLIR code completions
This commit adds code completion results to the MLIR LSP using
a new code completion context in the MLIR parser. This commit
adds initial completion for dialect, operation, SSA value, and
block names.

Differential Revision: https://reviews.llvm.org/D129183
2022-07-07 13:35:54 -07:00
Robert Suderman b9e642afd1 [mlir][spirv] Add path for math.round to spirv for OCL and GLSL
OpenCL's round function matches `math.round` so we can directly lower to
the op, this includes adding the op definition to the SPIRV OCL ops.
GLSL does not guarantee rounding direction so we include custom rounding
code to guarantee correct rounding direction.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D129236
2022-07-07 19:20:20 +00:00
Krzysztof Drewniak cab44c515c [mlir][AMDGPU] Add --chipset option to AMDGPUToROCDL
Because the buffer descriptor structure (the V#) has no backwards-compatibility
guarentees, and since said guarantees have been violated in practice
(see https://github.com/llvm/llvm-project/issues/56323 ), and since
the `targetIsRDNA` attribute isn't something that higher-level clients can set
in general, make the lowering of the amdgpu dialect to rocdl take a --chipset
option.

Note that this option is a string because adding a parser for the Chipset
struct to llvm::cl wasn't working out.

Reviewed By: herhut

Differential Revision: https://reviews.llvm.org/D129228
2022-07-07 14:58:13 +00:00
Nicolas Vasilache 5230710933 [mlir][Transform] Make applyToOne return a DiagnosedSilenceableFailure
This revision revisits the implementation of applyToOne and its handling
of recoverable errors as well as propagation of null handles.
The implementation is simplified to always require passing a vector<Operation*>
in which the results are returned, resulting in less template instantiation magic.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D129185
2022-07-07 07:32:04 -07:00
Alex Zinenko 8e03bfc368 [mlir] Transform dialect: introduce merge_handles op
This Transform dialect op allows one to merge the lists of Payload IR
operations pointed to by several handles into a single list associated with one
handle. This is an important Transform dialect usability improvement for cases
where transformations may temporarily diverge for different groups of Payload
IR ops before converging back to the same script. Without this op, several
copies of the trailing transformations would have to be present in the
transformation script.

Depends On D129090

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D129110
2022-07-07 13:19:46 +02:00
Alex Zinenko ff6e5508d6 [mlir] Structured transforms: introduce op splitting
Introduce a new transformation on structured ops that splits the iteration
space into two parts along the specified dimension. The index at which the
splitting happens may be static or dynamic. This transformation can be seen as
a rudimentary form of index-set splitting that only supports the splitting
along hyperplanes parallel to the iteration space hyperplanes, and is therefore
decomposable into per-dimension application.

It is a key low-level transformation that enables independent scheduling for
different parts of the iteration space of the same op, which hasn't been
possible previously. It may be used to implement, e.g., multi-sized tiling. In
future, peeling can be implemented as a combination of split-off amount
computation and splitting.

The transformation is conceptually close to tiling in its separation of the
iteration and data spaces, but cannot be currently implemented on top of
TilingInterface as the latter does not properly support `linalg.index`
offsetting.

Note that the transformation intentionally bypasses folding of
`tensor.extract_slice` operations when creating them as this folding was found
to prevent repeated splitting of the same operation because due to internal
assumptions about extract/insert_slice combination in dialect utilities.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D129090
2022-07-07 13:19:44 +02:00
Markus Böck 9f186bb125 [mlir][ods] Make Type- and AttrInterfaces also `Type`s and `Attr`s
By making TypeInterfaces and AttrInterfaces, Types and Attrs respectively it'd then be possible to use them anywhere where a Type or Attr may go. That is within the arguments and results of an Op definition, in a RewritePattern etc.

Prior to this change users had to separately define a Type or Attr, with a predicate to check whether a type or attribute implements a given interface. Such code will be redundant now.
Removing such occurrences in upstream dialects will be part of a separate patch.

As part of implementing this patch, slight refactoring had to be done. In particular, Interfaces cppClassName field was renamed to cppInterfaceName as it "clashed" with TypeConstraints cppClassName. In particular Interfaces cppClassName expected just the class name, without any namespaces, while TypeConstraints cppClassName expected a fully qualified class name.

Differential Revision: https://reviews.llvm.org/D129209
2022-07-07 11:54:47 +02:00
Matthias Springer a28ce1a42b [mlir][vector][bufferize] Fix transfer_write dropping mask operand
Differential Revision: https://reviews.llvm.org/D129253
2022-07-07 10:02:13 +02:00
jacquesguan 362240e09e [mlir][Math] Support fold PowFOp with constant dense.
This patch adds a conditional binary constant folder which allow to exit when the constants not meet the fold condition. And use it for PowFOp to make it able to fold the constant dense.

Differential Revision: https://reviews.llvm.org/D129108
2022-07-07 10:13:08 +08:00
Aart Bik 6d8e2f1e51 [mlir][sparse] implement simple reshaping (expand/collapse)
The revision makes a start with implementing expand/collapse reshaping
for sparse tensors. When either source or destination is sparse, but
other is dense, the "cheap" dense reshape can be used prior to converting
from or to a sparse tensor.

Note1
sparse to sparse reshaping is still TBD.

Note2
in the long run, we may want to implement a "view" into a sparse tensor so that the operation remains cheap and does not require data shuffling

Reviewed By: wrengr

Differential Revision: https://reviews.llvm.org/D129031
2022-07-06 14:34:30 -07:00
Dominik Adamski 2c915e3b26 [mlir][OpenMP] Add if clause to OpenMP simd construct
This patch adds if clause to OpenMP TableGen for simd construct.

Reviewed By: peixin

Differential Revision: https://reviews.llvm.org/D128940

Signed-off-by: Dominik Adamski <dominik.adamski@amd.com>
2022-07-06 07:24:48 -05:00
jacquesguan cf74b7ec80 [mlir][Vector] Fold InsertOp(SplatOp(X), SplatOp(X)) to SplatOp(X).
This patch folds InsertOp(SplatOp(X), SplatOp(X)) to SplatOp(X).

Differential Revision: https://reviews.llvm.org/D129058
2022-07-06 11:27:23 +08:00
River Riddle ab9cdf09f4 [mlir:Parser] Don't use strings for the "ugly" form of Attribute/Type syntax
This commit refactors the syntax of "ugly" attribute/type formats to not use
strings for wrapping. This means that moving forward attirbutes and type formats
will always need to be in some recognizable form, i.e. if they use incompatible
characters they will need to manually wrap those in a string, the framework will
no longer do it automatically.

This has the benefit of greatly simplifying how parsing attributes/types work, given
that we currently rely on some extremely complicated nested parser logic which is
quite problematic for a myriad of reasons; unecessary complexity(we create a nested
source manager/lexer/etc.), diagnostic locations can be off/wrong given string escaping,
etc.

Differential Revision: https://reviews.llvm.org/D118505
2022-07-05 16:20:30 -07:00
Markus Böck f2beca908d [mlir][tblgen] Consistently use `$_ctxt` instead of `$_ctx`
With the exceptions of AttrOrTypeParameter and DerivedAttr, all of MLIR consistently uses $_ctxt as the substitute variable for the MLIRContext in TableGen C++ code.
Usually this does not matter unless one where to reuse some code in multiple fields but it is still needlessly inconsistent and prone to error.

This patch fixes that by consistently using _$ctxt everywhere.

Differential Revision: https://reviews.llvm.org/D129153
2022-07-05 20:06:52 +02:00
Min-Yih Hsu a2158374ba [mlir][LLVMIR] Apply CallOp/CallableInterface on suitable operations
- Applying CallOpInterface on CallOp and InvokeOp.
  - Applying CallableInterface on LLVMFuncOp.

We're testing the changes using CallGraph, which uses both interfaces.

Differential Revision: https://reviews.llvm.org/D129026
2022-07-05 09:27:00 -07:00
Matthias Springer 6c3c5f8069 [mlir][memref] Improve type inference for rank-reducing subviews
The result shape of a rank-reducing subview cannot be inferred in the general case. Just the result rank is not enough. The only thing that we can infer is the layout map.

This change also improves the bufferization patterns of tensor.extract_slice and tensor.insert_slice to fully support rank-reducing operations.

Differential Revision: https://reviews.llvm.org/D129144
2022-07-05 16:49:07 +02:00
Matthias Springer cc6462a475 [mlir][tensor][bufferize][NFC] Clean up test case
Insert -split-input-file flag to make the test cases more stable.

Differential Revision: https://reviews.llvm.org/D129143
2022-07-05 16:10:39 +02:00
Groverkss 3c043ab007 [MLIR][Affine] Allow `<=` in IntegerSet constraints
This patch extends the affine parser to allow affine constraints with `<=`.
This is useful in writing unittests for Presburger library and test in general.

The internal storage and printing of IntegerSet is still in the original format.

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D129046
2022-07-05 12:17:31 +01:00
Nicolas Vasilache df5c981be3 [mlir][Linalg] Add DropUnitDims support for tensor::ParallelInsertSliceOp.
ParallelInsertSlice behaves similarly to tensor::InsertSliceOp in its
rank-reducing properties.
This revision extends rank-reducing rewrite behavior and reuses most of the
existing implementation.

Differential Revision: https://reviews.llvm.org/D129091
2022-07-05 01:36:13 -07:00
Christian Sigg 3e01af093f [mlir] Add InferIntRangeInterface to gpu.launch
Infers block/grid dimensions/indices or ranges of such dimensions/indices.

Reviewed By: krzysz00

Differential Revision: https://reviews.llvm.org/D129036
2022-07-05 07:14:54 +02:00
Benoit Jacob c3839c0b46 CombineContractBroadcast should not create dims unused in LHS+RHS
Differential Revision: https://reviews.llvm.org/D129087
2022-07-04 16:52:35 +00:00
Shraiysh Vaishay fdf505f3f2 [mlir][OpenMP] omp.task translation to LLVM IR
This patch adds translation for omp.task from OpenMPDialect to LLVM IR
Dialect and adds tests for the same.

Depends on D71989

Reviewed By: ftynse, kiranchandramohan, peixin, Meinersbur

Differential Revision: https://reviews.llvm.org/D123919
2022-07-04 21:03:02 +05:30
Nicolas Vasilache c9fb3c6ea6 [mlir][Tensor] Update ParallelInsertSlicOp semantics to match that of InsertSliceOp
This revision updates the op semantics to also allow rank-reducing behavior as well
as updates the implementation to reuse code between the sequential and the parallel
version of the op.

Depends on D128920

Differential Revision: https://reviews.llvm.org/D128985
2022-07-04 02:37:46 -07:00
Nicolas Vasilache 7fbf55c927 [mlir][Tensor] Move ParallelInsertSlice to the tensor dialect
This is moslty NFC and will allow tensor.parallel_insert_slice to gain
rank-reducing semantics by reusing the vast majority of the tensor.insert_slice impl.

Depends on D128857

Differential Revision: https://reviews.llvm.org/D128920
2022-07-04 01:53:12 -07:00
Shraiysh Vaishay 1063dfc028 [mlir][openmp] Added omp.taskloop
This patch adds omp.taskloop operation to OpenMP Dialect along with
tests.

Reviewed By: peixin

Differential Revision: https://reviews.llvm.org/D127380
2022-07-04 12:50:07 +05:30
jacquesguan e98e13ac8f [mlir][Vector] Fold ShuffleOp(SplatOp(X), SplatOp(X)) to SplatOp(X).
This patch folds ShuffleOp(SplatOp(X), SplatOp(X)) to SplatOp(X).

Differential Revision: https://reviews.llvm.org/D128969
2022-07-04 10:06:06 +08:00
Groverkss d71a8bb157 [MLIR][Affine] Allow affine-expr on RHS in IntegerSet
Currently, the parser for IntegerSet, only allows constraints like:

```
affine-constraint ::= affine-expr `>=` `0`
                    | affine-expr `==` `0`
```

This form is sometimes unreadable and painful to use when writing unittests
for Presburger library and tests in general.

This patch extends the parser to allow affine constraints with affine-expr on
the RHS:

```
affine-constraint ::= affine-expr `>=` `affine-expr`
                    | affine-expr `==` `affine-expr`
```

The internal storage and printing of IntegerSet is still in the original format.

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D128915
2022-07-03 16:22:39 +01:00
lewuathe 5148c685e3 [mlir][complex] Inverse canonicalization between exp and log
We can canonicalize consecutive complex.exp and complex.log which are inverse functions each other.

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D128966
2022-07-03 09:26:55 +09:00
Eric Kunze b7f4335d6a [mlir][tosa] Update TOSA transpose_conv2d to match spec
The TOSA Specification doesn't have a dilation attribute for transpose_conv2d,
and the padding array is of size 4. (top,bottom,left,right).

This change updates the dialect to match the specification, and updates the lit
tests to match the dialect changes.

Differential Revision: https://reviews.llvm.org/D127332
2022-07-01 19:10:28 +00:00
Nicolas Vasilache 6a57d8fba5 [mlir][vector] Untangle TransferWriteDistribution and avoid crashing in the 0-D case.
This revision avoids a crash in the 0-D case of distributing vector.transfer ops out of
vector.warp_execute_on_lane_0.
Due to the code complexity and lack of documentation, it took untangling the implementation
before realizing that the simple fix was to fail in the 0-D case.
The rewrite is still very useful to understand this code better.

Differential Revision: https://reviews.llvm.org/D128793
2022-07-01 00:15:34 -07:00
jacquesguan 8f45c5862f [mlir][Vector] Fold InsertStridedSliceOp of ExtractStridedSliceOp.
This patch supports to fold InsertStridedSliceOp(ExtractStridedSliceOp(dst), dst) to dst.

Differential Revision: https://reviews.llvm.org/D128903
2022-07-01 11:43:35 +08:00
jacquesguan 91ab4d4231 [mlir][Vector] Fold InsertStridedSliceOp of two splat with the same input to splat.
This patch folds InsertStridedSliceOp(SplatOp(X):src_type, SplatOp(X):dst_type) to SplatOp(X):dst_type.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D128891
2022-07-01 10:46:47 +08:00
Fangrui Song 62a4e6ab15 [mlir] Remove unneeded cl::ZeroOrMore for ListOption variables. NFC 2022-06-30 19:04:44 -07:00
wren romano 46394861a3 [mlir][tblgen] Improving error messages
This differential improves two error conditions, by detecting them earlier and by providing better messages to help users understand what went wrong.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D128555
2022-06-30 18:25:53 -07:00
Mogball c095afcba6 [mlir] Add Dead Code Analysis
This patch implements the analysis state classes needed for sparse data-flow analysis and implements a dead-code analysis using those states to determine liveness of blocks, control-flow edges, region predecessors, and function callsites.

Depends on D126751

Reviewed By: rriddle, phisiart

Differential Revision: https://reviews.llvm.org/D127064
2022-06-30 13:51:25 -07:00
Javed Absar c2ecf16224 [mlir][Inliner] Support recursion in Inliner
This fixes  Bug https://github.com/llvm/llvm-project/issues/53492
 and uses InlineHistory to track recursive inlining.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D127072
2022-06-30 18:52:45 +01:00
Benoit Jacob 030b36a44c Useful error when input dim is unused by LHS/RHS.
Differential Revision: https://reviews.llvm.org/D128925
2022-06-30 17:46:05 +00:00
Christopher Bate 670eee08ce [mlir][VectorToGPU] Fix support for i4, col-major operand support
For the conversion to nvgpu `mma.sync` and `ldmatrix` pathways, the code
was missing support for the `i4` data type. While fixing this, another
bug was discoverd that caused the number of ldmatrix tiles calculated for
certain operand types and configurations to be incorrect. This change
fixes both issues and adds additional tests.

Differential Revision: https://reviews.llvm.org/D128074
2022-06-30 10:26:59 -06:00
Nicolas Vasilache 178f9bd63c [mlir][Linalg] Uniformize SplitReduction transforms and add option to use Bufferization::AllocTensor
This revision merges the 2 split_reduction transforms and adds extra control by using attributes.

SplitReduction is known to require a concrete additional buffer to store tempoaray information.
Add an option to introduce a `bufferization.alloc_tensor` instead of `linalg.init_tensor`.
This behaves better with subset-based tiling and bufferization.

Differential Revision: https://reviews.llvm.org/D128722
2022-06-30 03:32:23 -07:00
Aart Bik e057f25dee [mlir][sparse] auto-insertion of conversion to resolve cycles
When the iteration graph is cyclic (even after several attempts using less and less constraints), the current sparse compiler bails out, and no rewriting hapens. However, this revision adds some new logic where the sparse compiler tries to find a single input sparse tensor that breaks the cycle, and then adds a proper sparse conversion operation. This way, more incoming kernels can be handled!

Note, the resulting code is not optimal (although it keeps more or less proper "sparse" complexity), and more improvements should be added (especially when the kernel directly yields without computation, such as the transpose example). However, handling is better than not handling ;-)

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D128847
2022-06-29 18:28:18 -07:00
Min-Yih Hsu d41028610b [mlir] Prevent SubElementInterface from going into infinite recursion
Since only mutable types and attributes can go into infinite recursion
inside SubElementInterface::walkSubElement, and there are only a few of
them (mutable types and attributes), we introduce new traits for Type
and Attribute: TypeTrait::IsMutable and AttributeTrait::IsMutable,
respectively. They indicate whether a type or attribute is mutable.
Such traits are required if the ImplType defines a `mutate` function.

Then, inside SubElementInterface, we use a set to record visited mutable
types and attributes that have been visited before.

Differential Revision: https://reviews.llvm.org/D127537
2022-06-29 13:58:02 -07:00