Commit Graph

5606 Commits

Author SHA1 Message Date
ergawy 0c8f9b8099 [MLIR][SPIRV] Add initial support for OpSpecConstantComposite.
This commit adds support to SPIR-V's composite specialization constants.
These are specialization constants which are composed of other spec
constants (whehter scalar or composite), regular constatns, or undef
values.

This commit adds support for parsing, printing, verification, and
(De)serialization.

A few TODOs are still in order:
- Supporting more types of constituents; currently, only scalar spec constatns are supported.
- Extending `spv._reference_of` to support composite spec constatns.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D88568
2020-10-02 15:18:16 -04:00
Thomas Raoux d1c8e179d8 [mlir][vector] Add canonicalization patterns for extractMap/insertMap
Add basic canonicalization patterns for the extractMap/insertMap to allow them
to be folded into Transfer ops.
Also mark transferRead as memory read so that it can be removed by dead code.

Differential Revision: https://reviews.llvm.org/D88622
2020-10-02 10:13:11 -07:00
zhanghb97 2fc0d4a8e8 [mlir] Add Float Attribute, Integer Attribute and Bool Attribute subclasses to python bindings.
Based on PyAttribute and PyConcreteAttribute classes, this patch implements the bindings of Float Attribute, Integer Attribute and Bool Attribute subclasses.
This patch also defines the `mlirFloatAttrDoubleGetChecked` C API which is bound with the `FloatAttr.get_typed` python method.

Differential Revision: https://reviews.llvm.org/D88531
2020-10-03 00:32:51 +08:00
Stephen Neuendorffer 34d12c15f7 [MLIR] Better message for FuncOp type mismatch
Previously the actual types were not shown, which makes the message
difficult to grok in the context of long lowering chains.  Also, it
appears that there were no actual tests for this.

Differential Revision: https://reviews.llvm.org/D88318
2020-10-02 09:31:44 -07:00
Diego Caballero a611f9a5c6 [mlir] Fix call op conversion in bare-ptr calling convention
We hit an llvm_unreachable related to unranked memrefs for call ops
with scalar types. Removing the llvm_unreachable since the conversion
should gracefully bail out in the presence of unranked memrefs. Adding
tests to verify that.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D88709
2020-10-02 08:48:21 -07:00
Nicolas Vasilache 86b14d0969 [mlir] Attempt to appease gcc-5 const char* -> StringLiteral conversion issu 2020-10-02 10:53:48 -04:00
George Mitenkov d4568ed743 [MLIR][LLVM] Fixed `topologicalSort()` to iterative version
Instead of recursive helper method `topologicalSortImpl()`,
sort's implementation is moved to `topologicalSort()` function's
body directly. `llvm::ReversePostOrderTraversal` is used to create
a traversal of blocks in reverse post order.

Reviewed By: kiranchandramohan, rriddle

Differential Revision: https://reviews.llvm.org/D88544
2020-10-02 13:48:27 +03:00
Nicolas Vasilache cf9503c1b7 [mlir] Add subtensor_insert operation
Differential revision: https://reviews.llvm.org/D88657
2020-10-02 06:32:31 -04:00
Nicolas Vasilache 787bf5e383 [mlir] Add canonicalization for the `subtensor` op
Differential revision: https://reviews.llvm.org/D88656
2020-10-02 06:05:52 -04:00
Nicolas Vasilache e3de249a4c [mlir] Add a subtensor operation
This revision introduces a `subtensor` op, which is the counterpart of `subview` for a tensor operand. This also refactors the relevant pieces to allow reusing the `subview` implementation where appropriate.

This operation will be used to implement tiling for Linalg on tensors.
2020-10-02 05:35:30 -04:00
Stephen Neuendorffer 47df8c57e4 [MLIR] Updates around MemRef Normalization
The documentation for the NormalizeMemRefs pass and the associated MemRefsNormalizable
traits was confusing and not on the website.  This update clarifies the language
around the difference between a MemRef Type, an operation that accesses the value of
MemRef Type, and better documents the limitations of the current implementation.
This patch also includes some basic debugging information for the pass so people
might have a chance of figuring out why it doesn't work on their code.

Differential Revision: https://reviews.llvm.org/D88532
2020-10-01 21:11:41 -07:00
MaheshRavishankar c6ea095b97 [mlir][Linalg] NFC : Move fusion on tensors to separate file.
Differential Revision: https://reviews.llvm.org/D88633
2020-10-01 09:50:37 -07:00
Nicolas Vasilache a81b938b6d [mlir][Linalg] Fix ASAN bug
```
 LinalgTilingOptions &setTileSizes(ValueRange ts)
```
makes it all too easy to create stack-use-after-return errors.

In particular, c694588fc5 introduced one such issue.

Instead just take a copy in the lambda and be done with it.
2020-10-01 06:57:35 -04:00
River Riddle f050553490 [mlir] Split Dialect::addOperations into two functions
The current implementation uses a fold expression to add all of the operations at once. This is really nice, but apparently the lifetime of each of the AbstractOperation instances is for the entire expression which may lead to a stack overflow for large numbers of operations. This splits the method in two to allow for the lifetime of the AbstractOperation to be properly scoped.
2020-09-30 18:03:14 -07:00
Geoffrey Martin-Noble d4e889f1f5 Remove `Ops` suffix from dialect library names
Dialects include more than just ops, so this suffix is outdated. Follows
discussion in
https://llvm.discourse.group/t/rfc-canonical-file-paths-to-dialects/621

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D88530
2020-09-30 18:00:44 -07:00
MaheshRavishankar c694588fc5 [mlir][Linalg] Add pattern to tile and fuse Linalg operations on buffers.
The pattern is structured similar to other patterns like
LinalgTilingPattern. The fusion patterns takes options that allows you
to fuse with producers of multiple operands at once.
- The pattern fuses only at the level that is known to be legal, i.e
  if a reduction loop in the consumer is tiled, then fusion should
  happen "before" this loop. Some refactoring of the fusion code is
  needed to fuse only where it is legal.
- Since the fusion on buffers uses the LinalgDependenceGraph that is
  not mutable in place the fusion pattern keeps the original
  operations in the IR, but are tagged with a marker that can be later
  used to find the original operations.

This change also fixes an issue with tiling and
distribution/interchange where if the tile size of a loop were 0 it
wasnt account for in these.

Differential Revision: https://reviews.llvm.org/D88435
2020-09-30 14:56:58 -07:00
Thomas Raoux dd14e58252 [mlir][vector] First step of vector distribution transformation
This is the first of several steps to support distributing large vectors. This
adds instructions extract_map and insert_map that allow us to do incremental
lowering. Right now the transformation only apply to simple pointwise operation
with a vector size matching the multiplicity of the IDs used to distribute the
vector.
This can be used to distribute large vectors to loops or SPMD.

Differential Revision: https://reviews.llvm.org/D88341
2020-09-30 13:14:55 -07:00
Christian Sigg e9b3884161 Add GDB prettyprinters for a few more MLIR types.
Reviewed By: dblaikie, jpienaar

Differential Revision: https://reviews.llvm.org/D87159
2020-09-30 21:22:47 +02:00
Eugene Zhulenev 655af658c9 [MLIR] Add async.value type to Async dialect
Return values from async regions as !async.value<...>.

Reviewed By: mehdi_amini, csigg

Differential Revision: https://reviews.llvm.org/D88510
2020-09-30 11:30:06 -07:00
Valentin Clement dd4fb7c8cf [mlir][openacc] Remove -allow-unregistred-dialect from ops and invalid tests
Switch to a dummy op in the test dialect so we can remove the -allow-unregistred-dialect
on ops.mlir and invalid.mlir. Change after comment on D88272.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D88587
2020-09-30 12:24:21 -04:00
Mahesh Ravishankar 892fdc923f [mlir][Linalg] Generalize the logic to compute reassociation maps
while folding tensor_reshape op.

While folding reshapes that introduce unit extent dims, the logic to
compute the reassociation maps can be generalized to handle some
corner cases, for example, when the folded shape still has unit-extent
dims but corresponds to folded unit extent dims of the expanded shape.

Differential Revision: https://reviews.llvm.org/D88521
2020-09-30 07:58:06 -07:00
Benjamin Kramer f33f8a2b30 Move AffineMapAttr into BaseOps.td
AffineMapAttr is already part of base, it's just impossible to refer to
it from ODS without pulling in the definition from Affine dialect.

Differential Revision: https://reviews.llvm.org/D88555
2020-09-30 16:22:53 +02:00
Jakub Lichman 0b17d4754a [mlir][Linalg] Tile sizes for Conv ops vectorization added as pass arguments
Current setup for conv op vectorization does not enable user to specify tile
sizes as well as dimensions for vectorization. In this commit we change that by
adding tile sizes as pass arguments. Every dimension with corresponding tile
size > 1 is automatically vectorized.

Differential Revision: https://reviews.llvm.org/D88533
2020-09-30 11:31:28 +00:00
Jakub Lichman 14088a6f5d [mlir] Added support for rank reducing subviews
This commit adds support for subviews which enable to reduce resulting rank
by dropping static dimensions of size 1.

Differential Revision: https://reviews.llvm.org/D88534
2020-09-30 11:15:18 +00:00
George Mitenkov 8c05c7c8d8 [MLIR][SPIRV] Support different function control in (de)serialization
Added support for different function control
in serialization and deserialization.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D88280
2020-09-30 12:25:36 +03:00
Frederik Gossen cdda7822d6 [MLIR][Standard] Add `atan2` to standard dialect
Differential Revision: https://reviews.llvm.org/D88168
2020-09-30 08:38:45 +00:00
Scott Todd 1c5aa8aeca [mlir] Update docs referencing OpTrait::Symbol.
Since https://reviews.llvm.org/D78522, Symbol is not a Trait itself.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D88512
2020-09-30 03:55:54 +00:00
Jacques Pienaar 4f0e0d9217 [mlir] Remove more OpBuilder args which are now injected
NFC. Some small changes to make things more consistent but primarily
avoiding old behavior without any further change.
2020-09-29 16:47:21 -07:00
Tim Shen f0506e4923 [MLIR] Avoid adding debuginfo for a function if it contains calls that has no debug info.
Also add a verifier pass to ExecutionEngine.

It's hard to come up with a test case, since mlir-opt always add location info after parsing it (?)

Differential Revision: https://reviews.llvm.org/D88135
2020-09-29 13:51:56 -07:00
Mehdi Amini eff9984dca Fix TODO in the mlir-cpu-runner/bare_ptr_call_conv.mlir test: call ops in bare-ptr calling convention is supported now (NFC)
This was fixed in a89fc12653.
2020-09-29 20:21:07 +00:00
Diego Caballero a89fc12653 [mlir] Support return and call ops in bare-ptr calling convention
This patch adds support for the 'return' and 'call' ops to the bare-ptr
calling convention. These changes also align the bare-ptr calling
convention code with the latest changes in the default calling convention
and reduce the amount of customization code needed.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D87724
2020-09-29 12:00:47 -07:00
Eugene Zhulenev 05a3b4fe30 [MLIR] Add Async dialect with trivial async.region operation
Start Async dialect for modeling asynchronous execution.

Reviewed By: mehdi_amini, herhut

Differential Revision: https://reviews.llvm.org/D88459
2020-09-29 11:11:08 -07:00
Stella Laurenzo 543922cd36 Adds MLIR C-API for marshaling Python capsules.
* Providing stable, C-accessible definitions for bridging MLIR Python<->C APIs, we eliminate inter-extension dependencies (i.e. they can all share a diamond dependency on the MLIR C-API).
* Just provides accessors for context and module right now.
* Needed in NPComp in ~a week or so for high level Torch APIs.

Differential Revision: https://reviews.llvm.org/D88426
2020-09-29 10:48:53 -07:00
Valentin Clement 9c77350b0c [mlir][openacc] Add shutdown operation
This patch introduces the acc.shutdown operation that represents an OpenACC shutdown directive.
Clauses are derived from the spec 2.14.2

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D88272
2020-09-29 13:13:09 -04:00
Valentin Clement 51323fe2b8 [mlir][openacc] Add init operation
This patch introduces the init operation that represents the init executable directive
from the OpenACC 3.0 specifications.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D88254
2020-09-29 10:59:02 -04:00
Valentin Clement cc3b8e730e [mlir][openacc] Add wait operation
This patch introduce the wait operation that represent the OpenACC wait directive.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D88125
2020-09-29 10:39:33 -04:00
Alex Zinenko 64c0c9f015 [mlir] Expose Dialect class and registration/loading to C API
- Add a minimalist C API for mlir::Dialect.
- Allow one to query the context about registered and loaded dialects.
- Add API for loading dialects.
- Provide functions to register the Standard dialect.

When used naively, this will require to separately register each dialect. When
we have more than one exposed, we can add variadic macros that expand to
individual calls.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D88162
2020-09-29 16:30:08 +02:00
Valentin Clement ecc9978071 [mlir][openacc] Add update operation
This patch introduce the update operation that represent the OpenACC update directive.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D88102
2020-09-29 09:57:57 -04:00
Nicolas Vasilache 6b649570cb [mlir][Linalg] Refactor Linalg op initTensors support - NFC
Manually-defined named ops do not currently support `init_tensors` or return values and may never support them. Add extra interface to the StructuredOpInterface so that we can still write op-agnostic transformations based on StructuredOpInterface.

This is an NFC extension in preparation for tiling on tensors.

Differential Revision: https://reviews.llvm.org/D88481
2020-09-29 09:56:38 -04:00
Nicolas Vasilache 074ab233ed [mlir][Linalg] Refactor Linalg creation of loops to allow passing iterArgs - NFC
This revision changes the signatures of helper function that Linalg uses to create loops so that they can also take iterArgs.
iterArgs are asserted empty to ensure no functional change.
This is a mechanical change in preparation of tiling on linalg on tensors to avoid  polluting the implementation with an NFC change.

Differential Revision: https://reviews.llvm.org/D88480
2020-09-29 09:51:11 -04:00
Andrzej Warzynski 6199219bbd [mlir] Fix shared libs build
The following change causes the shared libraries build
(BUILD_SHARED_LIBS=On) to fail:
  * https://reviews.llvm.org/D88351
This patch will fix that.

Differential Revision: https://reviews.llvm.org/D88484
2020-09-29 14:31:14 +01:00
Stephan Herhut edeff6e642 [mlir][GPU] Improve constant sinking in kernel outlining
The previous implementation did not support sinking simple expressions. In particular,
it is often beneficial to sink dim operations.

Differential Revision: https://reviews.llvm.org/D88439
2020-09-29 14:46:15 +02:00
Kiran Kumar T P f3ead88e9c [MLIR][OpenMP] Removed the ambiguity in flush op assembly syntax
Summary:
========
Bugzilla Ticket No: Bug 46884 [https://bugs.llvm.org/show_bug.cgi?id=46884]

Flush op assembly syntax was ambiguous:

Consider the below test case:
flush operation is not having any arguments.
But the next statement token i.e "%2" is read as the argument for flush operation and then translator issues an error.
***************************************************************
$ cat -n flush.mlir
     1  llvm.func @_QQmain(%arg0: !llvm.i32) {
     2    %0 = llvm.mlir.constant(1 : i64) : !llvm.i64
     3    %1 = llvm.alloca %0 x !llvm.i32 {in_type = i32, name = "a"} : (!llvm.i64) -> !llvm.ptr<i32>
     4    omp.flush
     5    %2 = llvm.load %1 : !llvm.ptr<i32>
     6    llvm.return
     7  }

$ mlir-translate -mlir-to-llvmir flush.mlir
flush.mlir:5:6: error: expected ':'
  %2 = llvm.load %1 : !llvm.ptr<i32>
     ^
***************************************************************

Solution:
=========
Introduced begin ( `(` ) and end token ( `)` ) to determince the begin and end of variadic arguments.

The patch includes code changes and testcase modifications.

Reviewed By: Valentin Clement, Mehdi AMINI

Differential Revision: https://reviews.llvm.org/D88376
2020-09-29 09:41:46 +05:30
Valentin Clement bbb5dc4923 [mlir][openacc] Add acc.data operation verifier
Add a basic verifier for the data operation following the restriction from the standard.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D88334
2020-09-28 21:22:32 -04:00
Mehdi Amini 9f9f89d44b Remove dependency from LLVM Dialect on the OpenMP dialect
The OmpDialect is in practice optional during translation to LLVM IR: the code is tolerant
to have a "nullptr" when not present / needed.

The dependency still exists on the export to LLVMIR.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D88351
2020-09-29 01:12:01 +00:00
Diego Caballero 93936da904 [mlir][Affine][VectorOps] Fix super vectorizer utility (D85869)
Adding missing code that should have been part of "D85869: Utility to
vectorize loop nest using strategy."

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D88346
2020-09-28 16:24:11 -07:00
Sean Silva a975be0e00 [mlir][shape] Make conversion passes more consistent.
- use select-ops to make the lowering simpler
- change style of FileCheck variables names to be consistent
- change some variable names in the code to be more explicit

Differential Revision: https://reviews.llvm.org/D88258
2020-09-28 14:55:42 -07:00
Aart Bik e9628955f5 [mlir] [VectorOps] Relaxed restrictions on vector.reduction types even more
Recently, restrictions on vector reductions were made more relaxed by
accepting any width signless integer and floating-point. This CL relaxes
the restriction even more by including unsigned and signed integers.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D88442
2020-09-28 13:38:03 -07:00
Aart Bik 54759cefdb [mlir] [VectorOps] changes to printing support for integers
(1) simplify integer printing logic by always using 64-bit print
(2) add index support (since vector<16xindex> is planned to be added)
(3) adjust naming convention print_x -> printX

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D88436
2020-09-28 11:43:31 -07:00
Stella Laurenzo 76753a597b Add FunctionType to MLIR C and Python bindings.
Differential Revision: https://reviews.llvm.org/D88416
2020-09-28 09:56:48 -07:00