Commit Graph

4398 Commits

Author SHA1 Message Date
Stephen Neuendorffer fef4ddf2f4 [MLIR] Fix typo in lib/Interfaces
This broke BUILD_SHARED_LIBS=on
2020-04-24 15:39:19 -07:00
River Riddle 0816de167a [mlir][DialectConversion] Add support for properly tracking replaceUsesOfBlockArgument
The current implementation of this method performs the replacement directly, and thus doesn't support proper back tracking.

Differential Revision: https://reviews.llvm.org/D78790
2020-04-24 12:37:32 -07:00
Lei Zhang 60f1d26366 Revert "[mlir][drr] NFC: avoid SmallVector when collecting substitution values"
This reverts commit 2f8b164ca2, which
causes a breakage on Clang 5.
2020-04-24 15:33:03 -04:00
River Riddle 0e2bd49370 [mlir][DictionaryAttr] Add a new getWithSorted and use it when possible
The elements of a DictionaryAttr are sorted by name. In many situations, e.g NamedAttributeList, we can guarantee that the elements are sorted on construction and remove the need to perform extra checks. In places with lots of calls to attribute methods, this leads to a good performance improvement.

Differential Revision: https://reviews.llvm.org/D78781
2020-04-24 12:23:32 -07:00
Stella Laurenzo 7720d6578c Add constructor to ShapedTypeComponents for unranked with element type.
Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, grosul1, frgossen, Kayjukh, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78774
2020-04-24 10:43:08 -07:00
Tres Popp dc9cff15a2 [MLIR] Add RecursiveSideEffects to Loops::ParallelOp.
Summary:
This is to specify that ParallelOp does not have side effects on its own
but has the effects of all operations executed in its region.

Differential Revision: https://reviews.llvm.org/D78707
2020-04-24 16:44:03 +02:00
Lei Zhang 2458cd27f1 [mlir] Add a ViewLikeOpInterface
This can help provide a common interface for view-like
ops so that for example Linalg's dependency analysis
can avoid relying on concrete ops.

Differential Revision: https://reviews.llvm.org/D78645
2020-04-24 10:02:56 -04:00
Lei Zhang 2f8b164ca2 [mlir][drr] NFC: avoid SmallVector when collecting substitution values
Now both Operation::operand_range and Operation::result_range have
.begin() and .end() for ranged-based for loop and we have
ValueRange for wrapping a single Value. We can remove the SmallVector
materialization!

Differential Revision: https://reviews.llvm.org/D78766
2020-04-24 09:36:47 -04:00
Haojian Wu 1cd84be17a [mlir] Add missing llvm::iterator_facade_base<...>::operator++ for
UseIterator;

This would fix our internal build.
2020-04-24 14:02:58 +02:00
Haojian Wu 500d378ee5 Fix -Wunused-variable warning, NFC. 2020-04-24 11:04:40 +02:00
Frederik Gossen 7e4b139a04 [MLIR] Ensure `gpu.func` must be inside a `gpu.module`.
Ensure that `gpu.func` is only used within the dedicated `gpu.module`.
Implement the constraint to the GPU dialect and adopt test cases.

Differential Revision: https://reviews.llvm.org/D78541
2020-04-24 07:17:48 +00:00
Rob Suderman 5b89c1dd68 [mlir] DenseStringElementsAttr added to default attribute types
Summary:
Implemented a DenseStringsElements attr for handling arrays / tensors of strings. This includes the
necessary logic for parsing and printing the attribute from MLIR's text format.

To store the attribute we perform a single allocation that includes all wrapped string data tightly packed.
This means no padding characters and no null terminators (as they could be present in the string). This
buffer includes a first chunk of data that represents an array of StringRefs, that contain address pointers
into the string data, with the length of each string wrapped. At this point there is no Sparse representation
however strings are not typically represented sparsely.

Differential Revision: https://reviews.llvm.org/D78600
2020-04-23 19:02:15 -07:00
Sean Silva 1b2c7877a4 Add support for IndexType inside DenseIntElementsAttr.
This also fixes issues discovered in the parsing/printing path.
2020-04-23 17:42:33 -07:00
River Riddle 48e9ef4320 [mlir] Give each OpResult its own use list
This revision removes the multi use-list to ensure that each result gets its own. This decision was made by doing some extensive benchmarking of programs that actually use multiple results. This results in a size increase of 1-word per result >1, but the common case of 1-result remains unaffected. A side benefit is that 0-result operations now shrink by 1-word.

Differential Revision: https://reviews.llvm.org/D78701
2020-04-23 16:28:55 -07:00
MaheshRavishankar 542668d1e2 [mlir][Linalg] Add support for fusing linalg.tensor_reshape with
linalg.generic operations.

Differential Revision: https://reviews.llvm.org/D78464
2020-04-23 13:41:47 -07:00
MaheshRavishankar d27ab5c240 [mlir][Linalg] NFC: Refactor fusion on tensors to enable extending
it to fusing different kinds of linalg operations on tensors.

The implementation of fusion on tensor was initially planned for just
GenericOps (and maybe IndexedGenericOps). With addition of
linalg.tensor_reshape, and potentially other such non-structured ops,
refactor the existing implementation to allow easier specification of
fusion between different linalg operations on tensors.

Differential Revision: https://reviews.llvm.org/D78463
2020-04-23 13:41:47 -07:00
Nicolas Vasilache 37d417bb0a [mlir][EDSC] Hotfix - Provide impl for `negate`
367229e100 retired ValueHandle but
mistakenly removed the implementation for `negate` which was not
tested and would result in linking errors.

This revision adds the implementation back and provides a test.
2020-04-23 14:18:47 -04:00
Feng Liu b578c92a98 [mlir/Quant] Allows to use 32 bits storage type
Differential Revision: https://reviews.llvm.org/D78671
2020-04-23 11:18:05 -07:00
MaheshRavishankar 9391941bd3 [mlir][StandardToSPIRV] Fix test cases where DCE removes all the code.
Differential Revision: https://reviews.llvm.org/D78727
2020-04-23 09:48:37 -07:00
Nicolas Vasilache 367229e100 [mlir][EDSC] Retire ValueHandle
The EDSC discussion [thread](https://llvm.discourse.group/t/evolving-builder-apis-based-on-lessons-learned-from-edsc/879) points out that ValueHandle has become an unnecessary level of abstraction since MLIR switch from `Value *` to `Value` everywhere.

This revision removes this level of indirection.
2020-04-23 11:01:16 -04:00
Marcel Koester c79227cabb [mlir] Extended Liveness analysis to support nested regions.
The current Liveness analysis does not support operations with nested regions.
This causes issues when querying liveness information about blocks nested within
operations. Furthermore, the live-in and live-out sets are not computed properly
in these cases.

Differential Revision: https://reviews.llvm.org/D77714
2020-04-23 16:19:54 +02:00
River Riddle 7f85adb54d [mlir][Standard] Allow select to use an i1 for vector and tensor values
It currently requires that the condition match the shape of the selected value, but this is only really useful for things like masks. This revision allows for the use of i1 to mean that all of the vector/tensor is selected. This also matches the behavior of LLVM select. A benefit of this change is that transformations that want to generate selects, like those on the CFG, don't have to special case vector/tensor. Previously the only way to generate  a select from an i1 was to use a splat, but that doesn't support dynamically shaped/unranked tensors.

Differential Revision: https://reviews.llvm.org/D78690
2020-04-23 04:50:09 -07:00
River Riddle 2fafe7ff59 [mlir][Standard] Add support for canonicalizing branches to passthrough blocks
This revision adds support for canonicalizing the following:

```
   br ^bb1
 ^bb1
   br ^bbN(...)

 br ^bbN(...)
```

Differential Revision: https://reviews.llvm.org/D78683
2020-04-23 04:42:02 -07:00
River Riddle af331bc52d [mlir][Standard] Add a canonicalization to simplify cond_br when the successors are identical
This revision adds support for canonicalizing the following:

```
cond_br %cond, ^bb1(A, ..., N), ^bb1(A, ..., N)

br ^bb1(A, ..., N)
```

 If the operands to the successor are different and the cond_br is the only predecessor, we emit selects for the branch operands.

```
cond_br %cond, ^bb1(A), ^bb1(B)

%select = select %cond, A, B
br ^bb1(%select)
```

Differential Revision: https://reviews.llvm.org/D78682
2020-04-23 04:42:02 -07:00
River Riddle 2f4b303d68 [mlir][Standard] Add canonicalization for collapsing pass through cond_br successors.
This revision adds support for the following canonicalization:

```
   cond_br %cond, ^bb1, ^bb2
 ^bb1
   br ^bbN(...)
 ^bb2
   br ^bbK(...)

   cond_br %cond, ^bbN(...), ^bbK(...)
```

Differential Revision: https://reviews.llvm.org/D78681
2020-04-23 04:42:01 -07:00
Kazuaki Ishizaki 9488f0d518 [mlir] NFC: fix broken links in doc of operation definitions
Differential Revision: https://reviews.llvm.org/D78696
2020-04-23 18:36:29 +09:00
Alexander Belyaev 21caba599e [MLIR] Lower GenericAtomicRMWOp to llvm.cmpxchg.
Summary:
Lowering is pretty much a copy of AtomicRMWOp -> llvm.cmpxchg
pattern.

Differential Revision: https://reviews.llvm.org/D78647
2020-04-23 09:29:34 +02:00
Kazuaki Ishizaki 4330d783e7 [mlir] NFC: Fix trivial typo under Dialects
Differential Revision: https://reviews.llvm.org/D78090
2020-04-23 14:28:41 +09:00
Sean Silva 7b5497f258 Isolate zero_whitespace parser test into its own file.
Summary:
This test is in a different file because it contains a literal NUL
character, which causes various tools to treat it as a binary file.
Hence it is useful to have this test kept in a separate, rarely-changing
file.

Differential Revision: https://reviews.llvm.org/D78689
2020-04-22 19:58:40 -07:00
Denis Khalikov 1009177d49 [mlir][vulkan-runner] Add support for integer types.
Summary:
Add support for memrefs with element type as integer type
and simple test.

Differential Revision: https://reviews.llvm.org/D78560
2020-04-22 19:42:39 +03:00
Christopher Tetreault 2dea3f1298 [SVE] Add new VectorType subclasses
Summary:
Introduce new types for fixed width and scalable vectors.

Does not remove getNumElements yet so as to not break code during transition
period.

Reviewers: deadalnix, efriedma, sdesmalen, craig.topper, huntergr

Reviewed By: sdesmalen

Subscribers: jholewinski, arsenm, jvesely, nhaehnle, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, liufengdb, kerbowa, Joonsoo, grosul1, frgossen, lldb-commits, tschuett, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm, #lldb

Differential Revision: https://reviews.llvm.org/D77587
2020-04-22 08:59:01 -07:00
Denis Khalikov ec16df7066 [mlir][vulkan-runner] Fix testsuite.
Summary: Fix testsuite after D78542.

Differential Revision: https://reviews.llvm.org/D78639
2020-04-22 18:24:15 +03:00
Frederik Gossen 0372db05bb [MLIR] Use nested symbol to identify kernel in `LaunchFuncOp`.
Summary:
Use a nested symbol to identify the kernel to be invoked by a `LaunchFuncOp` in the GPU dialect.
This replaces the two attributes that were used to identify the kernel module and the kernel within seperately.

Differential Revision: https://reviews.llvm.org/D78551
2020-04-22 07:44:29 +00:00
Frederik Gossen 648fc95083 [MLIR] Use `kernel` as a short hand for `gpu.kernel` attribute.
Summary:
Use the shortcu `kernel` for the `gpu.kernel` attribute of `gpu.func`.
The parser supports this and test cases are easier to read.

Differential Revision: https://reviews.llvm.org/D78542
2020-04-22 07:38:30 +00:00
Frederik Gossen 2813802746 [MLIR] Fix test case for kernel attribute.
Summary:
Fix a broken test case in the `invalid.mlir` lit test case.
`expect` was missing its `e`.

Differential Revision: https://reviews.llvm.org/D78540
2020-04-22 07:27:39 +00:00
Alexander Belyaev 146d52e732 [MLIR] Verify there are no side-effecting ops in GenericAtomicRMWOp body.
Differential Revision: https://reviews.llvm.org/D78559
2020-04-22 09:02:58 +02:00
Stephan Herhut c22876b550 [MLIR] Add extra locking during cubin generation.
We also need to lock the LLVMDialect mutex when initializing
LLVM targets or destroying llvm modules concurrently. Added another
scoped lock to that effect.

Differential Revision: https://reviews.llvm.org/D78580
2020-04-22 08:57:45 +02:00
Alexander Belyaev 84e4c09995 [MLIR] Update documentation for loop.parallel.
Differential Revision: https://reviews.llvm.org/D78562
2020-04-22 08:48:49 +02:00
Mehdi Amini 8dc790b933 Add `//` before the banner displayed in `--print-ir-before/after-all`
This is making the output file (when the stream is a file) a valid MLIR
file.

Differential Revision: https://reviews.llvm.org/D78604
2020-04-22 04:40:15 +00:00
River Riddle cf60700853 [mlir] Remove braces to avoid ambiguous constructor of operand range 2020-04-21 11:20:36 -07:00
Pierre Oechsel 128d72751f [mlir] [linalg] Specify alignment during promotion.
The buffer allocated by a promotion can be subject to other transformations afterward. For example it could be vectorized, in which case it is needed to ensure that this buffer is memory-aligned.

Differential Revision: https://reviews.llvm.org/D78556
2020-04-21 18:13:40 +02:00
Nicolas Vasilache 538ac26f25 [mlir][Linalg] Create a named batch_matmul op and pipe it through.
This revision is the first in a set of improvements that aim at allowing
more generalized named Linalg op generation from a mathematical
specification.

This revision allows creating a new op and checks that the parser,
printer and verifier are hooked up properly.

This opened up a few design points that will be addressed in the future:
1. A named linalg op has a static region builder instead of an
explicitly parsed region. This is not currently compatible with
assemblyFormat so a custom parser / printer are needed.
2. The convention for structured ops and tensor return values needs to
evolve to allow tensor-land and buffer land specifications to agree
3. ReferenceIndexingMaps and referenceIterators will need to become
static to allow building attributes at parse time.
4. Error messages will be improved once we have 3. and we pretty print
in custom form.

Differential Revision: https://reviews.llvm.org/D78327
2020-04-21 12:09:46 -04:00
Jean-Michel Gorius 585a0af379 [mlir][NFC] Fix typo in the standalone dialect README. 2020-04-21 16:55:04 +02:00
Pierre Oechsel 49202476e6 [mlir] [linalg] Fix transform-patterns test.
Unfortunately FileCheck ignores directives with whitespace between the directive and the colon (`CHECK  :` for example), thus most of the directives of this test were ignored.

Differential Revision: https://reviews.llvm.org/D78548
2020-04-21 12:53:45 +02:00
River Riddle 2eda87dfbe [mlir][SCCP] Add support for propagating constants across inter-region control flow.
This is possible by adding two new ControlFlowInterface additions:

- A new interface, RegionBranchOpInterface
This interface allows for region holding operations to describe how control flows between regions. This interface initially contains two methods:

* getSuccessorEntryOperands
Returns the operands of this operation used as the entry arguments when entering the region at `index`, which was specified as a successor by `getSuccessorRegions`. when entering. These operands should correspond 1-1 with the successor inputs specified in `getSuccessorRegions`, and may be a subset of the entry arguments for that region.

*  getSuccessorRegions
Returns the viable successors of a region, or the possible successor when branching from the parent op. This allows for describing which regions may be executed when entering an operation, and which regions are executed after having executed another region of the parent op. For example, a structured loop operation may always enter into the loop body region. The loop body region may branch back to itself, or exit to the operation.

- A trait, ReturnLike
This trait signals that a terminator exits a region and forwards all of its operands as "exiting" values.

These additions allow for performing more general dataflow analysis in the presence of region holding operations.

Differential Revision: https://reviews.llvm.org/D78447
2020-04-21 02:59:25 -07:00
River Riddle 152d29cc74 [mlir][Transforms] Add pass to perform sparse conditional constant propagation
This revision adds the initial pass for performing SCCP generically in MLIR. SCCP is an algorithm for propagating constants across control flow, and optimistically assumes all values to be constant unless proven otherwise. It currently supports branching control, with support for regions and inter-procedural propagation being added in followups.

Differential Revision: https://reviews.llvm.org/D78397
2020-04-21 02:59:25 -07:00
Pierre Oechsel 12dcb89dad [mlir] [linalg] Only promote selected buffers.
The promotion transformation is promoting all input and output buffers of the transformed op. The user might want to only promote some of these buffers.

Differential Revision: https://reviews.llvm.org/D78498
2020-04-21 11:50:08 +02:00
River Riddle b87531ca68 [mlir] Fix getTypes() support for result ranges. 2020-04-20 17:18:42 -07:00
Sean Silva 22219cfc6a Fix inlining multi-block callees with type conversion.
The previous code result a mismatch between block argument types and
predecessor successor args when a type conversion was needed in a
multiblock case. It was assuming the replaced result types matched the
region result types.

Also, slighly improve the debug output from the inliner.

Differential Revision: https://reviews.llvm.org/D78415
2020-04-20 16:54:01 -07:00
Eric Christopher 2d9a02a63a Update LLVMOps for CreateShuffleVector deprecation and rework
creation string.

Differential Revision: https://reviews.llvm.org/D78519
2020-04-20 15:50:29 -07:00
Jacques Pienaar 9ba37b3bf2 [mlir][ods] Add materialize derived attribute method
Summary:
Generate method to generate a DictionaryAttr with attribute values of
derived attribute. If a conversion back from the derived attribute C++
type to Attribute is not defined, then attempting to materialize such an
op's derived attributes would result in runtime failure.

This allows to treat derived attributes and attributes of an op in more
uniform manner where needed. The derived attributes are not added to the
operation but returned as new attribute instead.

Differential Revision: https://reviews.llvm.org/D78302
2020-04-20 13:13:04 -07:00
Uday Bondhugula 2d231c703d [MLIR] NFC clean up loop tiling test cases
Summary:
Improve the checks and drop redundant ones. Rename the outlined maps
better.

Reviewers: andydavis1, nicolasvasilache

Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, Joonsoo, grosul1, frgossen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78514
2020-04-21 01:13:46 +05:30
Uday Bondhugula 3dff8c9109 [MLIR] Fix affine loop tiling utility upper bound bug
Fix intra-tile upper bound setting in a scenario where the tile size was
larger than the trip count.

Differential Revision: https://reviews.llvm.org/D78505
2020-04-21 00:54:01 +05:30
Lei Zhang 92bf405ea6 [mlir][ods] Update doc regarding attribute definitions
Differential Revision: https://reviews.llvm.org/D78044
2020-04-20 11:58:12 -04:00
Lei Zhang f83d502feb [mlir][spirv] NFC: remove unnecessary `%N =` in test CHECKs 2020-04-20 11:52:29 -04:00
Lei Zhang ba49096817 [mlir][spirv] Lower memref with dynamic dimensions to runtime arrays
memref types with dynamic dimensions do not have a compile-time
known size. They should be mapped to SPIR-V runtime array types.

Differential Revision: https://reviews.llvm.org/D78197
2020-04-20 11:48:47 -04:00
Alexander Belyaev 871beba234 [MLIR] Add AtomicRMWRegionOp.
https://llvm.discourse.group/t/rfc-add-std-atomic-rmw-op/489

Differensial revision: https://reviews.llvm.org/D78352
2020-04-20 17:13:28 +02:00
Alexander Belyaev def3e10eac [MLIR] Add #include "llvm/ADT/SmallPtrSet.h" back to LoopUtils.h. 2020-04-20 10:21:18 +02:00
Alexander Belyaev ad9988f4da [MLIR] Move `replaceAllUsesExcept` from LoopUtil.h to Value.h.
Differential Revision: https://reviews.llvm.org/D78426
2020-04-20 09:21:06 +02:00
Mehdi Amini 73c33fcf56 Fix one more link for a Rationale doc moved under Rationale/ 2020-04-19 17:03:35 +00:00
Mehdi Amini 9909424544 Fix documentation link to MlirSpirvAbi
Differential Revision: https://reviews.llvm.org/D78394
2020-04-19 16:53:19 +00:00
Mehdi Amini 040fd340fa Fix one more doc links after moving the document under Tutorials 2020-04-19 16:52:05 +00:00
Mehdi Amini 0f5440cfaf Fix more broken doc links after some moved under the Rationale category 2020-04-19 16:49:30 +00:00
Uday Bondhugula 9412e4c9c6 [MLIR] NFC Fix/clarify line in const usage rationale doc
Update misleading line in conclusions. Although the application to IR
objects is stated earlier, the concluding section contradicts it in
isolation.

Differential Revision: https://reviews.llvm.org/D78446
2020-04-19 11:55:53 +05:30
Uday Bondhugula 2abd50a359 [MLIR] Mark dominance methods const
This change is in line with MLIR's coding style
https://mlir.llvm.org/getting_started/DeveloperGuide/
and also consistent with the dominance methods in LLVM.

Differential Revision: https://reviews.llvm.org/D78445
2020-04-19 11:53:20 +05:30
Mehdi Amini eafffdf6a8 Fix broken website link: Use absolute URL to point back to the source on GitHub 2020-04-19 04:54:31 +00:00
Mehdi Amini cee633c8e2 Fix broken doc links to DefiningAttributesAndTypes.md after move to Tutorials/ 2020-04-19 04:52:37 +00:00
Mehdi Amini 9197e62ce4 Fix broken doc links to QuickstartRewrites.md after move under Tutorials 2020-04-19 04:51:03 +00:00
Mehdi Amini 2b36288f45 Fix relative links in Rationale docs following move to subfolder 2020-04-19 04:47:15 +00:00
Mehdi Amini 6bbd9cad26 Fix broken docs links by using relative paths in the Linalg Rationale 2020-04-19 04:44:49 +00:00
Mehdi Amini 42154ea105 Fix broken doc links (Rationale.md -> Rationale/Rationale.md) 2020-04-19 04:42:08 +00:00
Mehdi Amini 1b012a9146 Fix broken docs links (WritingAPass.md was renamed PassManagement.md) 2020-04-19 04:38:56 +00:00
Uday Bondhugula ecddafd84a [MLIR] NFC affine for op tiling cleanup / utility rename
Rename mlir::tileCodeGen -> mlir::tilePerfectlyNested to be consistent.
NFC clean up tiling utility code, drop dead code, better comments.
Expose isPerfectlyNested and reuse.

Differential Revision: https://reviews.llvm.org/D78423
2020-04-19 00:53:34 +05:30
Uday Bondhugula f043677f6d [MLIR] Make isPerfectlyNested check more efficient
Make mlir::isPerfectlyNested more efficient; use O(1) check instead of
O(N) size() method.

Differential Revision: https://reviews.llvm.org/D78428
2020-04-18 23:34:49 +05:30
Denis Khalikov a48f0a3c7e [mlir][vulkan-runner] Simplify vulkan launch call op.
Summary:
Workgroup size is written into the kernel. So to properly modelling
vulkan launch, we have to skip local workgroup size for vulkan launch
call op.

Differential Revision: https://reviews.llvm.org/D78307
2020-04-18 16:49:47 +03:00
Lucy Fox a0d5e54966 [MLIR] Update tutorial to add missing tests and bring directory paths and code snippets up to date.
Summary:
The tests referred to in Chapter 3 of the tutorial were missing from the tutorial test
directory; this adds those missing tests. This also cleans up some stale directory paths and code
snippets used throughout the tutorial.

Differential Revision: https://reviews.llvm.org/D76809
2020-04-17 20:15:16 -07:00
Lucy Fox a6b427167e [MLIR] Update tutorial to add missing tests and bring directory paths and code snippets up to date.
Summary:
The tests referred to in Chapter 3 of the tutorial were missing from the tutorial test
directory; this adds those missing tests. This also cleans up some stale directory paths and code
snippets used throughout the tutorial.

Differential Revision: https://reviews.llvm.org/D76809
2020-04-17 20:15:15 -07:00
Lucy Fox 495cf27291 [MLIR] Update tutorial to add missing tests and bring directory paths and code snippets up to date.
Summary:
The tests referred to in Chapter 3 of the tutorial were missing from the tutorial test
directory; this adds those missing tests. This also cleans up some stale directory paths and code
snippets used throughout the tutorial.

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, aartbik, liufengdb, Joonsoo, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76809
2020-04-17 20:15:15 -07:00
aartbik 186709c6e0 [mlir] [VectorOps] Progressive lowering of vector.broadcast
Summary:
Rather than having a full, recursive, lowering of vector.broadcast
to LLVM IR, it is much more elegant to have a progressive lowering
of each vector.broadcast into a lower dimensional vector.broadcast,
until only elementary vector operations remain. This results
in more elegant, step-wise code, that is easier to understand.
Also makes some optimizations in the generated code.

Reviewers: nicolasvasilache, mehdi_amini, andydavis1, grosul1

Reviewed By: nicolasvasilache

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, grosul1, frgossen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78071
2020-04-16 21:02:27 -07:00
Stephen Neuendorffer 26805f0b64 [MLIR][cmake] Use DEPENDS instead of add_dependencies()
add_llvm_library() sometimes needs access to the dependencies in order to
generate new targets.  Using DEPENDS allows this.

Differential Revision: https://reviews.llvm.org/D78321
2020-04-16 15:53:13 -07:00
Nicolas Vasilache 40d139c620 [mlir][Linalg] NFC - Split out EDSCs that require a Folder
Summary: This is an NFC cleanup in preparation for end-to-end named Linalg ops.

Differential Revision: https://reviews.llvm.org/D78331
2020-04-16 18:06:05 -04:00
Stephen Neuendorffer 314f00a034 [MLIR][cmake] Remove redundant add_dependencies()
Libraries declared as target_link_libraries() do not also need
to be declared as dependencies using add_dependencies().

Differential Revision: https://reviews.llvm.org/D78320
2020-04-16 14:41:54 -07:00
Alex Zinenko f072942fe2 [mlir] ODS: support operations with resizable operand lists
MLIR supports operations with resizable operand lists, but this property must
be indicated during the construction of such operations. It can be done
programmatically by calling a function on OperationState. Introduce an
ODS-internal trait `ResizableOperandList` to indicate such operations are use
it when generating the bodies of various `build` functions as well as the
`parse` function when the declarative assembly format is used.

Differential Revision: https://reviews.llvm.org/D78292
2020-04-16 23:30:34 +02:00
Stephen Neuendorffer f061295732 [MLIR] Complete refactoring of Affine dialect into sub-libraries.
There were some unused CMakeFiles for Affine/IR and Affine/EDSC.
This change builds separate MLIRAffineOps and MLIRAffineEDSC libraries
using those CMakeFiles.  This combination replaces the old MLIRAffine
library.

Differential Revision: https://reviews.llvm.org/D78317
2020-04-16 13:41:17 -07:00
Uday Bondhugula dfcc403b2d [MLIR] NFC use Operation::getParentWithTrait in alloca verifier
Use recently added accessor Operation::getParentWithTrait in alloca
verifier.

Differential Revision: https://reviews.llvm.org/D78296
2020-04-16 21:34:02 +05:30
Uday Bondhugula ea88dd8212 [MLIR] Fix MLIR build - add missing CMake dependency
This will fix a failure when using a linker sensitive to the order in
which libraries are passed.

Differential Revision: https://reviews.llvm.org/D78303
2020-04-16 20:47:28 +05:30
Nicolas Vasilache f54312277c [mlir][Linalg] Drop function attribute from generic ops.
The function attribute in generic ops is not paying for itself.
A region is the more standardized way of specifying a custom computation.
If needed this region can call a function directly.
This is deemed more natural than managing a dedicated function attribute.

This also simplifies named ops generation by trimming unnecessary complexity.

Differential Revision: https://reviews.llvm.org/D78266
2020-04-16 09:47:08 -04:00
Ulysse Beaugnon 11f093fab4 [MLIR] Add IndexAttr to primitive attributes kinds in tablegen.
OpBase.td defined attributes kind for all integer types expect index. This
commit fixes that by adding an IndexAttr attribute kind. Update the
respective tests.

Differential Revision: https://reviews.llvm.org/D78195
2020-04-16 14:59:26 +02:00
Benjamin Kramer d9c7fc658d Revert "[MLIR] Add IndexAttr to primitive attributes kinds in tablegen."
This reverts commit 997f33cfee. Breaks check-mlir

******************** TEST 'MLIR :: IR/attribute.mlir' FAILED ********************
Script:
--
: 'RUN: at line 1';   mlir-opt llvm-project/mlir/test/IR/attribute.mlir -split-input-file -verify-diagnostics | /FileCheck llvm-project/mlir/test/IR/attribute.mlir
--
Exit Code: 1

Command Output (stderr):
--
llvm-project/mlir/test/IR/attribute.mlir split at line #1:19:3: error: unexpected error: 'test.int_attrs' op requires attribute 'index_attr'
  "test.int_attrs"() {
  ^
llvm-project/mlir/test/IR/attribute.mlir split at line #120:6:3: error: unexpected error: 'test.int_attrs' op requires attribute 'index_attr'
  "test.int_attrs"() {
  ^
llvm-project/mlir/test/IR/attribute.mlir split at line #120:5:6: error: expected error "'si32_attr' failed to satisfy constraint: 32-bit signed integer attribute" was not produced
  // expected-error @+1 {{'si32_attr' failed to satisfy constraint: 32-bit signed integer attribute}}
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
llvm-project/mlir/test/IR/attribute.mlir split at line #133:5:3: error: unexpected error: 'test.int_attrs' op requires attribute 'index_attr'
  "test.int_attrs"() {
  ^
llvm-project/mlir/test/IR/attribute.mlir split at line #133:4:6: error: expected error "'ui32_attr' failed to satisfy constraint: 32-bit unsigned integer attribute" was not produced
  // expected-error @+1 {{'ui32_attr' failed to satisfy constraint: 32-bit unsigned integer attribute}}
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
llvm-project/mlir/test/IR/attribute.mlir:9:12: error: CHECK: expected string not found in input
 // CHECK: any_i32_attr = 5 : ui32
           ^
<stdin>:3:1: note: scanning from here
module {
^
<stdin>:21:28: note: possible intended match here
 "test.non_negative_int_attr"() {i32attr = 5 : i32, i64attr = 10 : i64} : () -> ()
2020-04-16 14:28:18 +02:00
Stephan Herhut 69040d5b0b [MLIR] Allow for multiple gpu modules during translation.
This change makes the ModuleTranslation threadsafe by locking on the
LLVMContext. Furthermore, we now clone the llvm module into a new
context when compiling to PTX similar to what the OrcJit does.

Differential Revision: https://reviews.llvm.org/D78207
2020-04-16 14:18:31 +02:00
Alexander Belyaev be9c3bdc44 [MLIR] Fix fusion of linalg.indexed_generic producer into tiled (Indexed)GenericOp.
Differential Revision: https://reviews.llvm.org/D78209
2020-04-16 10:45:17 +02:00
Lorenzo Chelini a60fdd2ba4 [MLIR] NFC after commit D77478.
Remove leftovers 'applyPatternsGreedily' from the codebase.

Differential Revision: https://reviews.llvm.org/D78274
2020-04-16 10:32:01 +02:00
Ulysse Beaugnon 997f33cfee [MLIR] Add IndexAttr to primitive attributes kinds in tablegen.
Summary:
OpBase.td defined attributes kind for all integer types expect index. This
commit fixes that by adding an IndexAttr attribute kind.

Differential Revision: https://reviews.llvm.org/D78195
2020-04-16 10:28:33 +02:00
Pierre Oechsel c2f628e46c [MLIR] [EDSC] Add folded_xxxx handles for common std instructions.
Differential Revision: https://reviews.llvm.org/D77729
2020-04-16 10:27:39 +02:00
Mehdi Amini a07e5b8574 Fix build by adding missing CMake link dependency
This would only fail when using a linker that is sensitive to the order
in which the libraries are passed on the command line (like bfd).
2020-04-16 03:49:21 +00:00
River Riddle 4f37450b2c [mlir][Inliner] Store the resolved call by-value instead of by-reference
This avoids asan failures as more calls may be added during inlining, invalidating the reference.

Differential Revision: https://reviews.llvm.org/D78258
2020-04-15 17:42:27 -07:00
Jeremy Bruestle 9f3ab92ec8 [MLIR] Improve support for 0-dimensional Affine Maps.
Summary:
Modified AffineMap::get to remove support for the overload which allowed
an ArrayRef of AffineExpr but no context (and gathered the context from a
presumed first entry, resulting in bugs when there were 0 results).

Instead, we support only a ArrayRef and a context, and a version which
takes a single AffineExpr.

Additionally, removed some now needless case logic which previously
special cased which call to AffineMap::get to use.

Reviewers: flaub, bondhugula, rriddle!, nicolasvasilache, ftynse, ulysseB, mravishankar, antiagainst, aartbik

Subscribers: mehdi_amini, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, bader, grosul1, frgossen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78226
2020-04-15 14:15:02 -07:00
Uday Bondhugula af5e83f569 [MLIR] Introduce utility to hoist affine if/else conditions
This revision introduces a utility to unswitch affine.for/parallel loops
by hoisting affine.if operations past surrounding affine.for/parallel.
The hoisting works for both perfect/imperfect nests and in the presence
of else blocks. The hoisting is currently to as outermost a level as
possible.  Uses a test pass to test the utility.
Add convenience method Operation::getParentWithTrait<Trait>.

Depends on D77487.

Differential Revision: https://reviews.llvm.org/D77870
2020-04-16 00:32:34 +05:30
Pierre Oechsel efcf0985ee [mlir] [EDSC] Add interface for yield-for loops.
Summary:
ModelBuilder was missing an api to easily generate yield-for-loops.
This diffs implements an interface allowing to write:
```
%2:2 = loop.for %i = %start to %end step %step iter_args(%arg0 = %init0, %arg1 = %init1) -> (f32, f32) {
  %sum = addf %arg0, %arg1 : f32
  loop.yield %arg1, %sum : f32, f32
}
%3 = addf %2#0, %2#1 : f32
```

as

```
auto results =
    LoopNestBuilder(&i, start, end, step, {&arg0, &arg1},  {init0, init1})([&] {
      auto sum = arg0 + arg1;
      loop_yield(ArrayRef<ValueHandle>{arg1, sum});
    });

// Add the two values accumulated by the yield-for-loop:
ValueHandle(results[0]) + ValueHandle(results[1]);
```

Differential Revision: https://reviews.llvm.org/D78093
2020-04-15 18:39:30 +02:00
Alex Zinenko 129cf84e69 [mlir] LLVM dialect: support globals without linkage keyword, assuming 'external'
Similarly to actual LLVM IR, and to `llvm.mlir.func`, allow the custom syntax
of `llvm.mlir.global` to omit the linkage keyword. If omitted, the linkage is
assumed to be external. This makes the modeling of globals in the LLVM dialect
more consistent, both within the dialect and with LLVM IR.

Differential Revision: https://reviews.llvm.org/D78096
2020-04-15 10:58:32 +02:00