Commit Graph

163 Commits

Author SHA1 Message Date
Jakub Lichman 2beacda4f6 [mlir][Linalg][Doc] Fix of misleading example in Property 2
Code example in MLIR Linalg doc fixed because it referenced non-existing variables and some parameters were of wrong types.

Differential Revision: https://reviews.llvm.org/D81633
2020-06-11 10:50:34 +02:00
Alexander Belyaev 250dcf61ae Revert "Revert "[MLIR] Lower shape.num_elements -> shape.reduce.""
This reverts commit a25f5cd70c.

Now the build with `-DBUILD_SHARED_LIBS=ON` is fixed.
2020-06-08 12:19:54 +02:00
Mehdi Amini a25f5cd70c Revert "[MLIR] Lower shape.num_elements -> shape.reduce."
This reverts commit e80617df89.

This broke the build with `-DBUILD_SHARED_LIBS=ON`
2020-06-07 19:32:36 +00:00
Alexander Belyaev e80617df89 [MLIR] Lower shape.num_elements -> shape.reduce.
Differential Revision: https://reviews.llvm.org/D81279
2020-06-07 16:39:21 +02:00
Jacques Pienaar b0921f68e1 [mlir] Add verify method to adaptor
This allows verifying op-indepent attributes (e.g., attributes that do not require the op to have been created) before constructing an operation. These include checking whether required attributes are defined or constraints on attributes (such as I32 attribute). This is not perfect (e.g., if one had a disjunctive constraint where one part relied on the op and the other doesn't, then this would not try and extract the op independent from the op dependent).

The next step is to move these out to a trait that could be verified earlier than in the generated method. The first use case is for inferring the return type while constructing the op. At that point you don't have an Operation yet and that ends up in one having to duplicate the same checks, e.g., verify that attribute A is defined before querying A in shape function which requires that duplication. Instead this allows one to invoke a method to verify all the traits and, if this is checked first during verification, then all other traits could use attributes knowing they have been verified.

It is a little bit funny to have these on the adaptor, but I see the adaptor as a place to collect information about the op before the op is constructed (e.g., avoiding stringly typed accessors, verifying what is possible to verify before the op is constructed) while being cheap to use even with constructed op (so layer of indirection between the op constructed/being constructed). And from that point of view it made sense to me.

Differential Revision: https://reviews.llvm.org/D80842
2020-06-05 09:47:37 -07:00
Alex Zinenko 5c5dafc534 [mlir] support materialization for 1-1 type conversions
Dialect conversion infrastructure supports 1->N type conversions by requiring
individual conversions to provide facilities to generate operations
retrofitting N values into 1 of the original type when N > 1. This
functionality can also be used to materialize explicit "cast"-like operations,
but it did not support 1->1 type conversions until now. Modify TypeConverter to
support materialization of cast operations for 1-1 conversions.

This also makes materialization specification more extensible following the
same pattern as type conversions. Instead of overloading a virtual function,
users or subclasses of TypeConversion can now register type-specific
materialization callbacks that will be called in order for the given type.

Differential Revision: https://reviews.llvm.org/D79729
2020-06-02 13:48:33 +02:00
Jacques Pienaar 31f40f603d [mlir] Add simple generator for return types
Take advantage of equality constrains to generate the type inference interface.
This is used for equality and trivially built types. The type inference method
is only generated when no type inference trait is specified already.

This reorders verification that changes some test error messages.

Differential Revision: https://reviews.llvm.org/D80484
2020-05-27 08:45:55 -07:00
Tharindu Rusira a3b5ccddcc Update DialectConversion.md
line 164: typo? baz.add should be bar.add.
`bar.add` -> `foo.add`
2020-05-26 15:24:54 +02:00
Alex Zinenko 60f443bb3b [mlir] Change dialect namespace loop->scf
All ops of the SCF dialect now use the `scf.` prefix instead of `loop.`. This
is a part of dialect renaming.

Differential Revision: https://reviews.llvm.org/D79844
2020-05-13 19:20:21 +02:00
Rahul Joshi 5633813bf3 [MLIR] Fix several misc issues in in Toy tutorial
Summary:
- Fix comments in several places
- Eliminate extra ' in AST dump and adjust tests accordingly

Differential Revision: https://reviews.llvm.org/D78399
2020-05-11 16:56:47 -07:00
Sean Silva 98eead8186 [mlir][Value] Add v.getDefiningOp<OpTy>()
Summary:
This makes a common pattern of
`dyn_cast_or_null<OpTy>(v.getDefiningOp())` more concise.

Differential Revision: https://reviews.llvm.org/D79681
2020-05-11 12:55:27 -07:00
Uday Bondhugula 57d361bd2f [MLIR][NFC] Rename op trait PolyhedralScope -> AffineScope
Rename op trait PolyhedralScope -> AffineScope for consistency.

Differential Revision: https://reviews.llvm.org/D79503
2020-05-07 00:19:56 +05:30
Reid Kleckner 932f0276ea [Support] Move LLD's parallel algorithm wrappers to support
Essentially takes the lld/Common/Threads.h wrappers and moves them to
the llvm/Support/Paralle.h algorithm header.

The changes are:
- Remove policy parameter, since all clients use `par`.
- Rename the methods to `parallelSort` etc to match LLVM style, since
  they are no longer C++17 pstl compatible.
- Move algorithms from llvm::parallel:: to llvm::, since they have
  "parallel" in the name and are no longer overloads of the regular
  algorithms.
- Add range overloads
- Use the sequential algorithm directly when 1 thread is requested
  (skips task grouping)
- Fix the index type of parallelForEachN to size_t. Nobody in LLVM was
  using any other parameter, and it made overload resolution hard for
  for_each_n(par, 0, foo.size(), ...) because 0 is int, not size_t.

Remove Threads.h and update LLD for that.

This is a prerequisite for parallel public symbol processing in the PDB
library, which is in LLVM.

Reviewed By: MaskRay, aganea

Differential Revision: https://reviews.llvm.org/D79390
2020-05-05 15:21:05 -07:00
Alex Zinenko 898f74c35d [mlir] NFC: update ::build signature in the tutorial document
This was missing from the original commit that changed the interface of
`::build` methods to take `OpBuilder &` instead of `Builder *.
2020-05-05 11:22:14 +02:00
Alexander Belyaev b79751e83d [MLIR] Add conversion from AtomicRMWOp -> GenericAtomicRMWOp.
Adding this pattern reduces code duplication. There is no need to have a
custom implementation for lowering to llvm.cmpxchg.

Differential Revision: https://reviews.llvm.org/D78753
2020-05-05 10:32:13 +02:00
Stephen Neuendorffer 93f7e525f5 [MLIR] Update documentation of cmake best practices 2020-05-04 20:47:58 -07:00
River Riddle cb9ae0025c [mlir] Add a new context flag for disabling/enabling multi-threading
This is useful for several reasons:
* In some situations the user can guarantee that thread-safety isn't necessary and don't want to pay the cost of synchronization, e.g., when parsing a very large module.

* For things like logging threading is not desirable as the output is not guaranteed to be in stable order.

This flag also subsumes the pass manager flag for multi-threading.

Differential Revision: https://reviews.llvm.org/D79266
2020-05-02 12:32:25 -07:00
River Riddle 0d5caa8940 [mlir][DenseStringElementsAttr] Add support for the Attribute based get* methods.
This was missed in the original revision. This allows for using the opaque Attribute accessors when the elements are strings.
2020-05-01 16:34:35 -07:00
Stephen Neuendorffer 2e628d008c [MLIR][docs] Update tutorial language around Op and Operation* and 'opaque'
Differential Revision: https://reviews.llvm.org/D79146
2020-05-01 11:26:38 -07:00
River Riddle 91dae57087 [mlir][DeclareOpInterfaceMethods] Allow specifying a set of methods to force declaration generation for.
Currently a declaration won't be generated if the method has a default implementation. Meaning that operations that wan't to override the default have to explicitly declare the method in the extraClassDeclarations. This revision adds an optional list parameter to DeclareOpInterfaceMethods to allow for specifying a set of methods that should always have the declarations generated, even if there is a default.

Differential Revision: https://reviews.llvm.org/D79030
2020-04-29 16:48:15 -07:00
River Riddle 983382f134 [mlir][Pass] Add support for generating local crash reproducers
This revision adds a mode to the crash reproducer generator to attempt to generate a more local reproducer. This will attempt to generate a reproducer right before the offending pass that fails. This is useful for the majority of failures that are specific to a single pass, and situations where some passes in the pipeline are not registered with a specific tool.

Differential Revision: https://reviews.llvm.org/D78314
2020-04-29 15:23:10 -07:00
Uday Bondhugula 480345381a [MLIR] Introduce op trait PolyhedralScope (revised)
(A previous version of this, dd2c639c3c, was
reverted.)

Introduce op trait PolyhedralScope for ops to define a new scope for
polyhedral optimization / affine dialect purposes, thus generalizing
such scopes beyond FuncOp. Ops to which this trait is attached will
define a new scope for the consideration of SSA values as valid symbols
for the purposes of polyhedral analysis and optimization. Update methods
that check for dim/symbol validity to work based on this trait.

Differential Revision: https://reviews.llvm.org/D79060
2020-04-29 16:08:23 +05:30
Kazuaki Ishizaki b2f5fd84e8 [mlir] NFC: fix trivial typo
Differential Revision: https://reviews.llvm.org/D79065
2020-04-29 14:47:56 +09:00
Dmitri Gribenko ef06016d73 Revert "[MLIR] Introduce op trait PolyhedralScope"
This reverts commit dd2c639c3c. It broke a
few things -- the explanation will be posted to the review thread.
2020-04-28 14:50:57 +02:00
Alex Zinenko bb1d976feb [mlir][flang] use OpBuilder& instead of Builder* in <Op>::build methods
As we start defining more complex Ops, we increasingly see the need for
Ops-with-regions to be able to construct Ops within their regions in
their ::build methods. However, these methods only have access to
Builder, and not OpBuilder. Creating a local instance of OpBuilder
inside ::build and using it fails to trigger the operation creation
hooks in derived builders (e.g., ConversionPatternRewriter). In this
case, we risk breaking the logic of the derived builder. At the same
time, OpBuilder::create, which is by far the largest user of ::build
already passes "this" as the first argument, so an OpBuilder instance is
already available.

Update all ::build methods in all Ops in MLIR and Flang to take
"OpBuilder &" instead of "Builder *". Note the change from pointer and
to reference to comply with the common style in MLIR, this also ensures
all other users must change their ::build methods.

Differential Revision: https://reviews.llvm.org/D78713
2020-04-28 10:42:08 +02:00
Uday Bondhugula dd2c639c3c [MLIR] Introduce op trait PolyhedralScope
Introduce op trait `PolyhedralScope` for ops to define a new scope for
polyhedral optimization / affine dialect purposes, thus generalizing
such scopes beyond FuncOp. Ops to which this trait is attached will
define a new scope for the consideration of SSA values as valid symbols
for the purposes of polyhedral analysis and optimization. Update methods
that check for dim/symbol validity to work based on this trait.

Differential Revision: https://reviews.llvm.org/D78863
2020-04-28 09:55:31 +05:30
Lei Zhang f5b1301ce8 [mlir][doc] Add missing ` that breaks rendering 2020-04-27 11:25:32 -04:00
Tres Popp 49d8625aef [MLIR] Remove document references to gpu.kernel_module and gpu.kernel.
Summary:
These have been replaced from attributes to operations gpu.module and
gpu.func respectively.

Differential Revision: https://reviews.llvm.org/D78803
2020-04-27 10:00:15 +02:00
Uday Bondhugula 81bed2a9a2 [MLIR]][DOC] Fix dimension validity constraint in affine dialect doc
Fix affine dialect documentation on valid dimensional values: they also
include affine.parallel IVs.

Differential Revision: https://reviews.llvm.org/D78855
2020-04-25 12:22:39 +05:30
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
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
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
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
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
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
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
River Riddle 2f21a57966 [llvm][STLExtras] Move the algorithm `interleave*` methods from MLIR to LLVM
These have proved incredibly useful for interleaving values between a range w.r.t to streams. After this revision, the mlir/Support/STLExtras.h is empty. A followup revision will remove it from the tree.

Differential Revision: https://reviews.llvm.org/D78067
2020-04-14 15:14:40 -07:00
Denis Khalikov ec99d6e62f [mlir][spirv] Add a `spirv::InterfaceVarABIAttr`.
Summary:
Add a proper dialect-specific attribute for interface variable ABI.

Differential Revision: https://reviews.llvm.org/D77941
2020-04-13 22:47:47 +03:00
Lei Zhang a290c3af9d [mlir][spirv] Improve stride support in array types
This commit added stride support in runtime array types. It also
adjusted the assembly form for the stride from `[N]` to `stride=N`.
This makes the IR more readable, especially for the cases where
one mix array types and struct types.

Differential Revision: https://reviews.llvm.org/D78034
2020-04-13 14:08:17 -04:00
River Riddle 8938dea44a [mlir][IR] Manually register command line options for MLIRContext and AsmPrinter
Summary: This revision makes the registration of command line options for these two files manual with `registerMLIRContextCLOptions` and `registerAsmPrinterCLOptions` methods. This removes the last remaining static constructors within lib/.

Differential Revision: https://reviews.llvm.org/D77960
2020-04-11 23:13:00 -07:00