Commit Graph

10260 Commits

Author SHA1 Message Date
Markus Böck 8652fc8453 [mlir][NFC] Fully qualify a default C++ string in Pattern.cpp 2022-02-03 11:50:37 +01:00
Markus Böck 7a9e3ef77a [mlir] Fix crash in RewriterGen when a `TypeConstraint` is not given an argument
The code assumes that a TypeConstraint in the additional constraints list specifies precisely one argument.
If the user were to not specify any, it'd result in a crash. If given more than one, the additional ones were ignored.

This patch fixes the crash and disallows user errors by adding a check that a single argument is supplied to the TypeConstraint

Differential Revision: https://reviews.llvm.org/D118763
2022-02-03 09:08:27 +01:00
River Riddle cf70f7ce8b [mlir] Remove dangling reference to std-bufferize which got removed 2022-02-02 15:04:40 -08:00
River Riddle 8e123ca65f [mlir:Standard] Remove support for creating a `unit` ConstantOp
This is completely unused upstream, and does not really have well defined semantics
on what this is supposed to do/how this fits into the ecosystem. Given that, as part of
splitting up the standard dialect it's best to just remove this behavior, instead of try
to awkwardly fit it somewhere upstream. Downstream users are encouraged to
define their own operations that clearly can define the semantics of this.

This also uncovered several lingering uses of ConstantOp that weren't
updated to use arith::ConstantOp, and worked during conversions because
the constant was removed/converted into something else before
verification.

See https://llvm.discourse.group/t/standard-dialect-the-final-chapter/ for more discussion.

Differential Revision: https://reviews.llvm.org/D118654
2022-02-02 14:45:12 -08:00
River Riddle ead1107257 [mlir] Move StandardOps/Utils to Arithmetic and sever a bunch of dependencies on Standard
The Utils.cpp file in StandardOps essentially just contains utilities for interacting with arithmetic
operations, and at this point makes more sense as a utility file for the arithemtic dialect.

Differential Revision: https://reviews.llvm.org/D118280
2022-02-02 14:45:12 -08:00
River Riddle dec8af701f [mlir] Move SelectOp from Standard to Arithmetic
This is part of splitting up the standard dialect. See https://llvm.discourse.group/t/standard-dialect-the-final-chapter/ for discussion.

Differential Revision: https://reviews.llvm.org/D118648
2022-02-02 14:45:12 -08:00
River Riddle 6a8ba3186e [mlir] Split std.splat into tensor.splat and vector.splat
This is part of the larger effort to split the standard dialect. This will also allow for pruning some
additional dependencies on Standard (done in a followup).

Differential Revision: https://reviews.llvm.org/D118202
2022-02-02 14:45:12 -08:00
River Riddle 1be88f5ab1 [mlir][NFC] Update remaining dialect operations to use `hasVerifier` instead of `verifier`
The verifier field is deprecated, and slated for removal.

Differential Revision: https://reviews.llvm.org/D118829
2022-02-02 13:34:31 -08:00
River Riddle 0d86e53e18 [mlir][NFC] Update PDL operations to use `hasVerifier` instead of `verifier`
The verifier field is deprecated, and slated for removal.

Differential Revision: https://reviews.llvm.org/D118828
2022-02-02 13:34:31 -08:00
River Riddle 094ede6d20 [mlir][NFC] Update GPU/SCF operations to use `hasVerifier` instead of `verifier`
The verifier field is deprecated, and slated for removal.

Differential Revision: https://reviews.llvm.org/D118827
2022-02-02 13:34:31 -08:00
River Riddle 4809da8eaf [mlir][NFC] Update Affine operations to use `hasVerifier` instead of `verifier`
The verifier field is deprecated, and slated for removal.

Differential Revision: https://reviews.llvm.org/D118826
2022-02-02 13:34:30 -08:00
River Riddle ef72cf4413 [mlir][NFC] Update OpenACC/OpenMP operations to use `hasVerifier` instead of `verifier`
The verifier field is deprecated, and slated for removal.

Differential Revision: https://reviews.llvm.org/D118825
2022-02-02 13:34:30 -08:00
River Riddle b98dc0351a [mlir][NFC] Update MemRef/Tensor operations to use `hasVerifier` instead of `verifier`
The verifier field is deprecated, and slated for removal.

Differential Revision: https://reviews.llvm.org/D118821
2022-02-02 13:34:30 -08:00
River Riddle bdc7ce975a [mlir][NFC] Update Vector operations to use `hasVerifier` instead of `verifier`
The verifier field is deprecated, and slated for removal.

Differential Revision: https://reviews.llvm.org/D118820
2022-02-02 13:34:30 -08:00
River Riddle 38abdddf6f [mlir][NFC] Update AMX/LLVM/NVVM/X86 vector operations to use `hasVerifier` instead of `verifier`
The verifier field is deprecated, and slated for removal.

Differential Revision: https://reviews.llvm.org/D118819
2022-02-02 13:34:29 -08:00
River Riddle f7d85f010f [mlir][NFC] Update SPIRV operations to use `hasVerifier` instead of `verifier`
The verifier field is deprecated, and slated for removal.

Differential Revision: https://reviews.llvm.org/D118817
2022-02-02 13:34:29 -08:00
River Riddle 4e190c58de [mlir][NFC] Update Toy operations to use `hasVerifier` instead of `verifier`
The verifier field is deprecated, and slated for removal.

Differential Revision: https://reviews.llvm.org/D118816
2022-02-02 13:34:28 -08:00
River Riddle 42e5f1d97b [mlir] Refactor how additional verification is specified in ODS
Currently if an operation requires additional verification, it specifies an inline
code block (`let verifier = "blah"`). This is quite problematic for various reasons, e.g.
it requires defining C++ inside of Tablegen which is discouraged when possible, but mainly because
nearly all usages simply forward to a static function `static LogicalResult verify(SomeOp op)`.
This commit adds support for a `hasVerifier` bit field that specifies if an additional verifier
is needed, and when set to `1` declares a `LogicalResult verify()` method for operations to
override. For migration purposes, the existing behavior is untouched. Upstream usages will
be replaced in a followup to keep this patch focused on the hasVerifier implementation.

One main user facing change is that what was one `MyOp::verify` is now `MyOp::verifyInvariants`.
This better matches the name this method is called everywhere else, and also frees up `verify` for
the user defined additional verification. The `verify` function when generated now (for additional
verification) is private to the operation class, which should also help avoid accidental usages after
this switch.

Differential Revision: https://reviews.llvm.org/D118742
2022-02-02 13:34:28 -08:00
Chia-hung Duan 91e8a63c20 [mlir] Support verification order (1/3)
This CL supports adding dependency between traits verifiers and the
dependency will be checked statically.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D115135
2022-02-02 18:25:44 +00:00
Arjun P 79728453b7 [MLIR][Presburger] Simplify checkExplicitRepresentation
This also gets rid of a clang-tidy warning.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D118780
2022-02-02 20:20:16 +05:30
Prashant Kumar 3cc5447728 [MLIR][Presburger] Use `SmallVector` instead of `std::vector` in `getLocalRepr`
Use `SmallVector` instead of `std::vector` in `getLocalRepr` function.
 Also, fix the casing of a variable.

Reviewed By: arjunp

Differential Revision: https://reviews.llvm.org/D118722
2022-02-02 19:57:15 +05:30
Arjun P 29d1651d7b [MLIR][Presburger] maybeLocalRepr: rename inEqualityPair -> inequalityPair 2022-02-02 18:59:50 +05:30
Arjun P ec10ff37e2 [MLIR][Presburger] Support isSubsetOf in PresburgerSet and IntegerPolyhedron
Also support isEqual in IntegerPolyhedron.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D118778
2022-02-02 18:44:14 +05:30
Arjun P 55459f67b4 [MLIR] PresburgerSet::isIntegerEmpty: address clang-tidy warning 2022-02-02 18:05:14 +05:30
Arjun P 81d3144ebf [MLIR][AffineAnalysis] Fix typo in comment (NFC) 2022-02-02 17:50:06 +05:30
Arjun P 255494144f [MLIR] Matrix: support matrix-vector multiplication
This just moves in the implementation from LinearTransform.

Reviewed By: Groverkss, bondhugula

Differential Revision: https://reviews.llvm.org/D118479
2022-02-02 17:41:14 +05:30
Nicolas Vasilache 3c3810e72e [mlir][vector] Avoid hoisting alloca'ed temporary buffers across AutomaticAllocationScope
This revision avoids incorrect hoisting of alloca'd buffers across an AutomaticAllocationScope boundary.
In the more general case, we will probably need a ParallelScope-like interface.

Differential Revision: https://reviews.llvm.org/D118768
2022-02-02 06:00:42 -05:00
Markus Böck 513ba61ca1 [mlir] Fully qualify generated C++ code in RewriterGen.cpp
By fully qualifying the use of any types and functions from the mlir namespace, users are not required to add using namespace mlir; into the C++ file including the Tablegen output.

Differential Revision: https://reviews.llvm.org/D118767
2022-02-02 11:57:57 +01:00
Nicolas Vasilache aea4929dbb [mlir][async] Add AutomaticAllocationScope to async::ExecuteOp
Differential Revision: https://reviews.llvm.org/D118761
2022-02-02 05:15:23 -05:00
gysit dc82547b17 [mlir][vector] Make write permutation lowering work with tensors.
Use type inference when building the TransferWriteOp in the TransferWritePermutationLowering. Previously, the result type has been set to Type() which triggers an assertion if the pattern is used with tensors instead of memrefs.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D118758
2022-02-02 09:21:10 +00:00
Mogball 42f87a0354 [mlir][ods] NFC Fix ASAN error in FormatParser
Some FormatElement subclasses contain `std::vector`. Since these use
BumpPtrAllocator, they need to be converted to trailing objects.
However, this is not a trivial fix so I will leave it as a FIXME and use
a workaround.
2022-02-02 04:29:57 +00:00
Bixia Zheng ae7ee655a9 [mlir][taco] Add a utility to create an MLIR sparse tensor from a file.
Move the functions that retrieve the supporting C library, compile an MLIR
module and build a JIT execution engine to mlir_pytaco_utils.

Add a function to create an MLIR sparse tensor from a file and return a pointer
to the MLIR sparse tensor as well as the shape of the sparse tensor.

Add unit tests.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D118496
2022-02-01 15:43:53 -08:00
Daniel Resnick 97fc568211 [mlir][capi] Add DialectRegistry to MLIR C-API
Exposes mlir::DialectRegistry to the C API as MlirDialectRegistry along with
helper functions. A hook has been added to MlirDialectHandle that inserts
the dialect into a registry.

A future possible change is removing mlirDialectHandleRegisterDialect in
favor of using mlirDialectHandleInsertDialect, which it is now implemented with.

Differential Revision: https://reviews.llvm.org/D118293
2022-02-01 13:42:06 -07:00
Mahesh Ravishankar a2361eb281 Avoid doing tile + fuse if tile sizes are zero.
Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D118576
2022-02-01 18:34:06 +00:00
Alexander Belyaev ebc8153786 Revert "Revert "[mlir] Purge `linalg.copy` and use `memref.copy` instead.""
This reverts commit 25bf6a2a9b.
2022-02-01 18:21:21 +01:00
Alex Zinenko 22fea18e5f [mlir] Better error message in PybindAdaptors.h
When attempting to cast a pybind11 handle to an MLIR C API object through
capsules, the binding code would attempt to directly access the "_CAPIPtr"
attribute on the object, leading to a rather obscure AttributeError when the
attribute was missing, e.g., on non-MLIR types. Check for its presence and
throw a TypeError instead.

Depends On D117646

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D117658
2022-02-01 17:49:18 +01:00
Nicolas Vasilache 31b7f8857f [mlir][vector][integration] Reactivate LLI in vector integration test.
The test introduced in https://reviews.llvm.org/D118006 was missing a return and would
introduce a non-0 return which would fail tests.
2022-02-01 08:00:50 -05:00
Nicolas Vasilache c2fa5ff5ad Temporarily disable LLI to investigate weird non 0 error code
Somehow the test introduced in https://reviews.llvm.org/D118006 produces the expected result but running
through lli with Intel SDE activated sneaks in an error code 2 (before this commit) or an error code 10
(after this commit).

The test as is is still meaningful in that the LLVMIR generation would crash if the `elementtype` is set
improperly.

Still, this should run with lli turned on.
2022-02-01 07:24:49 -05:00
Benjamin Kramer a0ea73394f [mlir] Attempt working around a GCC 5 bug
It doesn't like implicit `this` in generic lambdas.
2022-02-01 11:58:27 +01:00
Nicolas Vasilache 42398b5142 [mlir][LLVM] Add support for operand_attrs to InlineAsmOp
This revision adds enough support to allow InlineAsmOp to work properly with indirect memory constraints "*m".
These require an explicit "elementtype" TypeAttr on the operands to pass LLVM verification and need to be provided.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D118006
2022-02-01 05:56:14 -05:00
Prashant Kumar 1e7c464d2c [MLIR] Extract division representation from equality expressions.
Extract the division representation from equality constraints.
For example:
    32*k == 16*i + j - 31                 <-- k is the localVariable
    expr = 16*i + j - 31, divisor = 32
    k = (16*i + j - 32) floordiv 32
The dividend of the division is set to [16, 1, -32] and the divisor is set
to 32.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D117959
2022-02-01 16:24:28 +05:30
Christian Sigg 9b078f8fd2 [MLIR][arith] Mark addf/mulf as commutative
Following the discussion in D118318, mark `arith.addf/mulf` commutative.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D118600
2022-02-01 08:33:48 +01:00
Mogball 0bc0ad86e2 [mlir][ods] Unify Attr/TypeDef and Operation Format Parsing
Part 2 of 3 of unifying the assembly formats of attributes/types and operations.The last patch that introduced attribute/type formats (D111594) factored out the format lexer entirely. This patch factors out most of the format parsers such that the attribute/type and op parsers only need to implement handling for specific elements.

Certain things could be factored better (element verification, 'seen' variables) but the primary goal of factoring is so that features can be used across both assembly formats.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D117971
2022-02-01 07:28:37 +00:00
River Riddle 58e7bf78a3 [mlir] Add isa/dyn_cast support for dialect interfaces
This matches the same API usage as attributes/ops/types. For example:

```c++
Dialect *dialect = ...;

// Instead of this:
if (auto *interface = dialect->getRegisteredInterface<DialectInlinerInterface>())

// You can do this:
if (auto *interface = dyn_cast<DialectInlinerInterface>(dialect))
```

Differential Revision: https://reviews.llvm.org/D117859
2022-01-31 19:24:34 -08:00
River Riddle 6ec9fd20bd [mlir:Standard][NFC] Remove the dead Arithmetic op classes from Ops.td
These were dead after the arithmetic operations moved from Standard to the Arithmetic dialect.
2022-01-31 12:53:29 -08:00
Sanjoy Das 18e33ba9c9 Remove `mutable` and stray comment
The `mutable` was added back when `scope` was a `DataLayoutOpInterface`.

Differential Revision: https://reviews.llvm.org/D118643
2022-01-31 12:33:20 -08:00
bakhtiyar 149311b405 [async] Get the number of worker threads from the runtime.
Reviewed By: ezhulenev

Differential Revision: https://reviews.llvm.org/D117751
2022-01-31 12:06:01 -08:00
Sanjoy Das 697a5036cd Remove OpTrait, AttrTrait and TypeTrait
- Remove the `{Op,Attr,Type}Trait` TableGen classes and replace with `Trait`
  - Rename `OpTraitList` to `TraitList` and use it in a few places

The bulk of this change is a mechanical s/OpTrait/Trait/ throughout the codebase.

Reviewed By: rriddle, jpienaar, herhut

Differential Revision: https://reviews.llvm.org/D118543
2022-01-31 11:04:00 -08:00
Christian Sigg f278cf9cbc [MLIR][arith] More float op folders
Fold `arith.fadd %x, -0.0 -> %x` and similarly for `fsub`, `fmul`, `fdiv`.

Fold `arith.fmin %x, %x -> %x`, `arith.fmin %x, +inf -> %x` and similarly for `fmax`.

Reviewed By: pifon2a, mehdi_amini, bondhugula

Differential Revision: https://reviews.llvm.org/D118244
2022-01-31 19:31:48 +01:00
Alexander Belyaev 25bf6a2a9b Revert "[mlir] Purge `linalg.copy` and use `memref.copy` instead."
This reverts commit 016956b680.
Reverting it to fix NVidia build without being in a hurry.
2022-01-31 18:51:39 +01:00
Alexander Belyaev 016956b680 [mlir] Purge `linalg.copy` and use `memref.copy` instead.
Differential Revision: https://reviews.llvm.org/D118028
2022-01-31 18:25:56 +01:00
Matthias Springer 5523c1455a [mlir][bufferize][NFC] Move vector BufferizableOpInterface impl to vector dialect
Differential Revision: https://reviews.llvm.org/D118540
2022-02-01 00:28:28 +09:00
Matthias Springer 99ef9eebad [mlir][vector][NFC] Split into IR, Transforms and Utils
This reduces the dependencies of the MLIRVector target and makes the dialect consistent with other dialects.

Differential Revision: https://reviews.llvm.org/D118533
2022-01-31 19:17:09 +09:00
Mehdi Amini 081cff628a Add missing include to mlir/Target/LLVMIR/Import.h to be standalone (NFC) 2022-01-31 07:55:00 +00:00
Uday Bondhugula f8a2cd67b9 Support affine.load/store ops in fold-memref-subview-ops pass
Support affine.load/store ops in fold-memref-subview ops pass. The
existing pass just "inlines" the subview operation on load/stores by
inserting affine.apply ops in front of the memref load/store ops: this
is by design always consistent with the semantics on affine.load/store
ops and the same would work even more naturally/intuitively with the
latter.

Differential Revision: https://reviews.llvm.org/D118565
2022-01-31 10:10:49 +05:30
Uday Bondhugula 92ccb8cc50 [MLIR][NFC] Update SCF pass cmd line names to prefix scf
Update SCF pass cmd line names to prefix `scf`. This is consistent with
guidelines/convention on how to name dialect passes. This also avoids
ambiguity on the context given the multiple `for` operations in the
tree.

NFC.

Differential Revision: https://reviews.llvm.org/D118564
2022-01-31 07:09:30 +05:30
Alexandre Ganea dc3b9365b6 [mlir] Silence warnings when building with MSVC
Differential Revision: https://reviews.llvm.org/D118536
2022-01-30 17:31:35 -05:00
Sanjoy Das 8f66ab1c2e Replace OwningModuleRef with OwningOpRef<ModuleOp>
This addresses a TODO in BuiltinOps.h.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D118574
2022-01-30 14:07:10 -08:00
Matthias Springer dab72a35e9 [mlir][bufferize] Clean up remaining references to `tensor-constant-bufferize` 2022-01-31 05:02:11 +09:00
Mehdi Amini 446425f898 Apply clang-tidy fixes for llvm-include-order in AttrOrTypeFormatGen.cpp (NFC) 2022-01-30 19:49:23 +00:00
Mehdi Amini bb31503989 Apply clang-tidy fixes for performance-move-const-arg in TestLinalgCodegenStrategy.cpp (NFC) 2022-01-30 19:49:23 +00:00
Mehdi Amini d7ab71f7b9 Apply clang-tidy fixes for readability-identifier-naming in TosaOps.cpp (NFC) 2022-01-30 19:49:23 +00:00
Mehdi Amini 70ed93ec4c Apply clang-tidy fixes for readability-identifier-naming in PolynomialApproximation.cpp (NFC) 2022-01-30 19:49:22 +00:00
Mehdi Amini bb6119eb77 Apply clang-tidy fixes for performance-for-range-copy in SCFInterfaceImpl.cpp (NFC) 2022-01-30 19:49:22 +00:00
Mehdi Amini 3b3fbd56ec Apply clang-tidy fixes for modernize-use-equals-default in BufferizableOpInterface.cpp (NFC) 2022-01-30 19:49:22 +00:00
Mehdi Amini f65994c9f1 Apply clang-tidy fixes for readability-identifier-naming in AsyncToLLVM.cpp (NFC) 2022-01-30 19:49:22 +00:00
Matthias Springer 6700a26d5f [mlir][linalg][bufferize] Fix insertion point InitTensorElimination
There was a bug where some of the OpOperands needed in the replacement op were not in scope.

It does not matter where the replacement op is inserted. Any insertion point is OK as long as there are no dominance errors. In the worst case, the newly inserted op will bufferize out-of-place. This is no worse than not eliminating the InitTensorOp at all.

Differential Revision: https://reviews.llvm.org/D117685
2022-01-30 22:25:39 +09:00
Matthias Springer e448c793c6 [mlir][bufferize][NFC] Move std BufferizableOpInterfaceImpl to std dialect
Also reimplement `std-bufferize` in terms of BufferizableOpInterface-based bufferization. The old `std.select` bufferization pattern is no longer needed and deleted.

Differential Revision: https://reviews.llvm.org/D118559
2022-01-30 22:12:14 +09:00
Matthias Springer 19efe141f7 [mlir][bufferize][NFC] Move scf BufferizableOpInterface impl to scf dialect
Differential Revision: https://reviews.llvm.org/D118557
2022-01-30 21:53:33 +09:00
Matthias Springer ab47418df6 [mlir][bufferize] Merge tensor-constant-bufferize into arith-bufferize
The bufferization of arith.constant ops is also switched over to BufferizableOpInterface-based bufferization. The old implementation is deleted. Both implementations utilize GlobalCreator, now renamed to just `getGlobalFor`.

GlobalCreator no longer maintains a set of all created allocations to avoid duplicate allocations of the same constant. Instead, `getGlobalFor` scans the module to see if there is already a global allocation with the same constant value.

For compatibility reasons, it is still possible to create a pass that bufferizes only `arith.constant`. This pass (createConstantBufferizePass) could be deleted once all users were switched over to One-Shot bufferization.

Differential Revision: https://reviews.llvm.org/D118483
2022-01-30 21:37:48 +09:00
Sanjoy Das c080456d64 Delete dead code
Differential Revision: https://reviews.llvm.org/D118501
2022-01-28 20:01:35 -08:00
wren romano b85ed4e0e1 [mlir][sparse] Adding standard pipeline for tests.
Addresses https://bugs.llvm.org/show_bug.cgi?id=52409 aka https://github.com/llvm/llvm-project/issues/51751

Reviewed By: aartbik, mehdi_amini

Differential Revision: https://reviews.llvm.org/D117919
2022-01-28 15:11:12 -08:00
Krzysztof Drewniak e7d0dae76e [MLIR][GPU] Add missing #include to SerializeToHsaco.cpp
llvm/Support/Path.h was likely previously implicitly included, and a
refactoring removed that inclusion, breaking the pass.

Differential Revision: https://reviews.llvm.org/D118508
2022-01-28 22:56:38 +00:00
Krzysztof Drewniak c918c68f5c [MLIR] Factor out common parts of the TLike constraint
Type constraints such as BoolLike and SignlessIntegerLike appear to
have been defined by copy-paste and all share an underlying TypesLike
structure that can be factored out.

This also allows for defining additional constraints of a similar
form, such as F32Like.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D118382
2022-01-28 22:55:41 +00:00
Alexandre Ganea 1cf9876661 [mlir] Fix build after 83d59e05b2
Differential Revision: https://reviews.llvm.org/D118510
2022-01-28 17:21:30 -05:00
Aart Bik 0daa72a505 [mlir][sparse][pytaco] enable dimension ordering syntax
Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D118500
2022-01-28 13:33:04 -08:00
harsh 80e0bf1af1 Add vector.scan op
This patch adds the vector.scan op which computes the
scan for a given n-d vector. It requires specifying the operator,
the identity element and whether the scan is inclusive or
exclusive.

TEST: Added test in ops.mlir

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D117171
2022-01-28 20:07:57 +00:00
Bixia Zheng 91865cc027 [mlir][taco] Accept an integer list for the ordering when defining a tensor format.
The unit tests for PyTACO hasn't been upstreamed yet. A unit test for this
change will be added when we upstream all the unit tests for PyTACO.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D118417
2022-01-28 10:33:25 -08:00
Stella Stamenova c0861fcbb9 [mlir] Only build mlir-cpu-runner when the native arch is targeted
mlir-cpu-runner has a dependency on ExecutionEngine which is only built for the native arch. So currently mlir-cpu-runner does not link correctly when the native arch is not targeted.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D118422
2022-01-28 10:09:09 -08:00
Arjun P 6db019582a [MLIR] Introduce LexSimplex to support lexicographic optimization
This patch introduces a class LexSimplex that can currently be used to find the
lexicographically minimal rational point in an IntegerPolyhedron. This is a
series of patches leading to computing the lexicographically minimal integer
lattice point as well parametric lexicographic minimization.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D117437
2022-01-28 22:06:58 +05:30
Adrian Kuegel f40475c7fd [mlir] Move SCF utils implementations to SCF/Utils.
BEGIN_PUBLIC
[mlir] Move SCF utils implementations to SCF/Utils.
END_PUBLIC
2022-01-28 11:54:27 +01:00
Nikita Popov a4ad79c50a [MLIR] Remove some pointer element type accesses
Use the MLIR pointer element type, rather than the LLVM pointer
element type.
2022-01-28 09:50:52 +01:00
Nikita Popov f2c2a31dd7 [OpenMPIRBuilder] Store element type in AtomicOpValue
With opaque pointers, we can no longer derive this from the pointer
type, so we need to explicitly provide the element type the atomic
operation should work with.

Differential Revision: https://reviews.llvm.org/D118359
2022-01-28 09:35:11 +01:00
Adrian Kuegel c962b3fdf8 [mlir][Bazel][cmake] Add missing dependency.
After 2c7b0685e1 this dependency is needed.
2022-01-28 08:20:24 +01:00
Frederik Gossen 2c7b0685e1 Fix tensor.extract for complex elements 2022-01-28 04:33:15 +01:00
Aart Bik 35ece3beaa [mlir][sparse][pytaco] add PyTACO SpMM example
Also contains a few TODOs on future enhancements

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D118418
2022-01-27 17:26:22 -08:00
Mogball 1e3a02162d [mlir][scf] Update IfOp to have getInvocationBounds
This allows `scf.if` to be used by Control-Flow sink.

Depends on D115088

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D115089
2022-01-27 23:15:53 +00:00
Saurabh Jha fa90c9d5e7 [mlir] Set up boilerplate build for MLIR benchmarks
This is is the start of the MLIR benchmarks. It sets up a command
line tool along with conventions to define and run benchmarks
using mlir's python bindings.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D115174
2022-01-27 21:38:15 +00:00
Thomas Raoux a57ccad5a6 [VectorToGPU] Fix horizontal stride calculation for N-D memref
Fix a bug in how we calculate the stride of mma load/store ops for N-D
memrefs

Differential Revision: https://reviews.llvm.org/D118378
2022-01-27 13:35:56 -08:00
Stephen Neuendorffer 84fe34a0b7 [MLIR] Workaround for python detection problems.
Although cmake should be platform-independent, we've observed
that some aspects of Python detection don't work on all platforms,
even with recent versions of cmake.  This appears to be due to bugs
in the python detection logic, especially when the NumPy component
is required and not located within the python installation.
As a workaround, this patch first searches for "Development" before
searching for "Development.Module", which seems to workaround the
issue.

Differential Revision: https://reviews.llvm.org/D118148
2022-01-27 13:32:29 -08:00
natashaknk 024a1fab5c [tosa][mlir] Add dynamic shape support for remaining ops
Added support for concat, tile, pad, argmax and table ops

Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D118397
2022-01-27 11:25:38 -08:00
Matthias Springer 075e3fdda1 [mlir][bufferize] Move arith BufferizableOpInterface impl to arith dialect
Also switch the implementation of `-arith-bufferize` to BufferizableOpInterface.

Differential Revision: https://reviews.llvm.org/D118325
2022-01-28 01:40:22 +09:00
Benjamin Kramer b70366c9c4 [mlir][BufferOptimization] Use datalayout instead of a flag to find index size
This has the additional advantage of supporting more types.

Differential Revision: https://reviews.llvm.org/D118348
2022-01-27 13:50:29 +01:00
Benjamin Kramer 608cc6b163 [mlir][complex] Lower complex.constant to LLVM
This fixes a regression from 480cd4cb85

Differential Revision: https://reviews.llvm.org/D118347
2022-01-27 13:48:23 +01:00
Matthias Springer b2f5004259 Revert "[mlir][bufferize] Insert memref.cast ops during finalizing pass"
This reverts commit 1043107ce5.

This commit caused a breakage in `finalizing-bufferize.mlir`.
2022-01-27 20:48:58 +09:00
Matthias Springer dbd1bbced9 [mlir][linalg][bufferize] Support arith.index_cast bufferization
This is in preparation of switching `-tensor-constant-bufferize` and `-arith-bufferize` to BufferizableOpInterface-based implementations.

Differential Revision: https://reviews.llvm.org/D118324
2022-01-27 19:50:31 +09:00
Matthias Springer daf18108ec [mlir][tensor] Replace tensor-bufferize with BufferizableOpInterface impl
This commit switches the `tensor-bufferize` pass over to BufferizableOpInterface-based bufferization.

Differential Revision: https://reviews.llvm.org/D118246
2022-01-27 19:30:45 +09:00
Matthias Springer 1043107ce5 [mlir][bufferize] Insert memref.cast ops during finalizing pass
The pass can currently not handle to_memref(to_tensor(x)) folding where a cast is necessary. This is required with the new unified bufferization. There is already a canonicalization pattern that handles such foldings and it should be used during this pass.

Differential Revision: https://reviews.llvm.org/D117988
2022-01-27 19:06:53 +09:00
Marius Brehler 578122c18a [mlir] Don't emit unused labels
Stop the Cpp target from emitting unused labels. The previosly generated
code generated warning if `-Wunused-label` is passed to a compiler.

Co-authored-by: Simon Camphausen <simon.camphausen@iml.fraunhofer.de>

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D118154
2022-01-27 07:56:03 +00:00
Uday Bondhugula fa5c5230d9 [MLIR] NFC. Rename pass cmd-line to prefix affine
Prefix "affine-" to affine transform passes that were missing it -- to
avoid ambiguity and for uniformity. There were only two needed this.

Move mispaced affine coalescing test case file.

NFC.

Differential Revision: https://reviews.llvm.org/D118314
2022-01-27 13:01:39 +05:30
Uday Bondhugula 970f94d051 [MLIR] Fix integration tests broken by D118285
[MLIR] Fix integration tests broken by D118285.
2022-01-27 13:00:30 +05:30
River Riddle 9f85c198db [mlir] Finish replacing OwningRewritePatternList with RewritePatternSet
OwningRewritePatternList has been deprecated for ~10 months now, we can remove
the leftover using directives at this point.

Differential Revision: https://reviews.llvm.org/D118287
2022-01-26 23:11:02 -08:00
River Riddle 7d0426dd95 [mlir] Move ComposeSubView+ExpandOps from Standard to MemRef
These transformations already operate on memref operations (as part of
splitting up the standard dialect). Now that the operations have moved,
it's time for these transformations to move as well.

Differential Revision: https://reviews.llvm.org/D118285
2022-01-26 23:11:02 -08:00
River Riddle 6842ec42f6 [mlir][NFC] Add a using for llvm::SMLoc/llvm::SMRange to LLVM.h
These are used pervasively during parsing.

Differential Revision: https://reviews.llvm.org/D118291
2022-01-26 21:37:23 -08:00
River Riddle d10d49dce4 [mlir][NFC] Add a using for llvm::BitVector to LLVM.h
BitVector is becoming widespread enough that we should add a proper using.

Differential Revision: https://reviews.llvm.org/D118290
2022-01-26 21:37:23 -08:00
River Riddle e3cd80ea9f [mlir:Function][NFC] Use BitVector instead of ArrayRef for indices when removing arguments/results
We already convert to BitVector internally, and other APIs (namely Operation::eraseOperands)
already use BitVector as well. Switching over provides a common format between
API and also reduces the amount of format conversions necessary.

Fixes #53325

Differential Revision: https://reviews.llvm.org/D118083
2022-01-26 21:37:22 -08:00
River Riddle f4a368689f [mlir:PassOptions] Fix parsing of nested option values/better handle escaping
The option parser currently does not properly handle nested options, meaning that
in some cases we can print pass pipelines that we can't actually parse back in. For example,
from #52885 we currently can't parse in inliner pipelines that have nested pipeline strings.

This commit adds handling for string values (e.g. "...") and nested options
(e.g. `foo{baz{bar=10 pizza=11}}`).

Fixes #52885

Differential Revision: https://reviews.llvm.org/D118078
2022-01-26 21:37:22 -08:00
Aart Bik 11fb049954 [mlir][amx] add a full tile matrix mult integral example to integration tests
Reviewed By: dcaballe

Differential Revision: https://reviews.llvm.org/D118292
2022-01-26 17:10:01 -08:00
Aart Bik 19f67ee29e [mlir][amx] fix some whitespace issues in AMX tests
Reviewed By: dcaballe

Differential Revision: https://reviews.llvm.org/D118289
2022-01-26 16:00:03 -08:00
Mehdi Amini 7ebd22c504 Revert "[mlir][LLVM] Add support for operand_attrs to InlineAsmOp"
This reverts commit e6ce2c0b8d.

The test is failing in CI right now.
2022-01-26 23:59:24 +00:00
Aart Bik a5257ae277 [mlir][amx] add a full tile matrix mult example to integration tests
Rationale:
Demonstrates the maximum tile size allowed for the f32 <= bf16 x bf16 op

Reviewed By: dcaballe

Differential Revision: https://reviews.llvm.org/D118277
2022-01-26 14:13:30 -08:00
Jeremy Furtek 33185e66f2 [mlir] Add ODS support for enum attributes with grouped bit cases
This diff modifies the tablegen specification and code generation for
BitEnumAttr attributes in MLIR Operation Definition Specification (ODS) files.
Specifically:

- there is a new tablegen class for "none" values (i.e. no bits set)
- single-bit enum cases are specified via bit index (i.e. [0, 31]) instead of
  the resulting enum integer value
- there is a new tablegen class to represent a "grouped" bitwise OR of other
  enum values

This diff is intended as an initial step towards improving "fastmath"
optimization support in MLIR, to allow more precise control of whether certain
floating point optimizations are applied in MLIR passes. "Fast" math options
for floating point MLIR operations would (following subsequent RFC and
discussion) be specified by using the improved enum bit support in this diff.
For example, a "fast" enum value would act as an alias for a group of other
cases (e.g. finite-math-only, no-signed-zeros, etc.), in a way that is similar
to support in C/C++ compilers (clang, gcc).

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D117029
2022-01-26 21:01:01 +00:00
River Riddle 632a4f8829 [mlir] Move std.generic_atomic_rmw to the memref dialect
This is part of splitting up the standard dialect. The move makes sense anyways,
given that the memref dialect already holds memref.atomic_rmw which is the non-region
sibling operation of std.generic_atomic_rmw (the relationship is even more clear given
they have nearly the same description % how they represent the inner computation).

Differential Revision: https://reviews.llvm.org/D118209
2022-01-26 11:52:01 -08:00
River Riddle 480cd4cb85 [mlir] Move the complex support of std.constant to a new complex.constant operation
This is part of splitting up the standard dialect.

Differential Revision: https://reviews.llvm.org/D118182
2022-01-26 11:52:00 -08:00
River Riddle b88a4d72d9 [mlir:GPU] Replace reference to LLVMFuncOp with FuncOpInterface
The GPU dialect currently contains an explicit reference to  LLVMFuncOp
during verification to handle the situation where the kernel has already been
converted. This commit changes that reference to instead use FunctionOpInterface,
which has two main benefits:

* It allows for removing an otherwise unnecessary dependency on the LLVM dialect
* It removes hardcoded assumptions about the lowering path and use of the GPU dialect

Differential Revision: https://reviews.llvm.org/D118172
2022-01-26 11:52:00 -08:00
Benjamin Kramer f15014ff54 Revert "Rename llvm::array_lengthof into llvm::size to match std::size from C++17"
This reverts commit ef82063207.

- It conflicts with the existing llvm::size in STLExtras, which will now
  never be called.
- Calling it without llvm:: breaks C++17 compat
2022-01-26 16:55:53 +01:00
serge-sans-paille ef82063207 Rename llvm::array_lengthof into llvm::size to match std::size from C++17
As a conquence move llvm::array_lengthof from STLExtras.h to
STLForwardCompat.h (which is included by STLExtras.h so no build
breakage expected).
2022-01-26 16:17:45 +01:00
Matthias Springer 268524238e [mlir][bufferization] Add an option to use memref types without layout maps
This is for compatibility with existing bufferization passes. Also clean up memref type generation a bit.

Differential Revision: https://reviews.llvm.org/D118243
2022-01-27 00:03:34 +09:00
Nicolas Vasilache e6ce2c0b8d [mlir][LLVM] Add support for operand_attrs to InlineAsmOp
This revision adds enough support to allow InlineAsmOp to work properly with indirect memory constraints "*m".
These require an explicit "elementtype" TypeAttr on the operands to pass LLVM verification and need to be provided.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D118006
2022-01-26 07:42:35 -05:00
Nicolas Vasilache 9b6c2ea302 [mlir][Linalg] Add GenericOp self-copy on buffers folding
Reviewed By: pifon2a

Differential Revision: https://reviews.llvm.org/D118116
2022-01-26 05:56:31 -05:00
Alexander Batashev e9b4239fef [mlir][openmp] Custom syntax for `omp.target` operation
Add a custom parser and printer for `omp.target` operation.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D117539
2022-01-26 10:26:19 +00:00
Matthias Springer 18778b8863 [mlir] Fix merging of delayed registrations during DialectRegistry::appendTo
The existing implementation called DenseMap::insert, which is a no-op if the map already contains an entry with the same key.

Differential Revision: https://reviews.llvm.org/D118165
2022-01-26 17:28:42 +09:00
Rob Suderman 7c984be21a [mlir] Propagate arith.index_cast past tensor.extract
If we are extracting it is more useful to push the index_cast past the
extraction. This increases the chance the tensor.extract can evaluated at
compile time.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D118204
2022-01-25 22:16:07 -08:00
Rob Suderman d81a3c51e7 [mlir] Fold tensor.reshape operations into tensor.from_elements.
There is not much of a benefit to reshape a from element vs reloading it.
Updated to progagate shape manipulations into the output type of
tensor.from_elements.

Reviewed By: NatashaKnk

Differential Revision: https://reviews.llvm.org/D118201
2022-01-25 15:54:57 -08:00
MaheshRavishankar f3ab0ccd00 [mlir][Linalg] Add couple of convenience methods to `LinalgInterface`.
Add methods to
- Get block argument that is tied with an opOperand
- Get the yield value that is tied with a output opOperand.

Differential Revision: https://reviews.llvm.org/D118085
2022-01-25 11:46:11 -08:00
MaheshRavishankar ea1ac183f4 [mlir][Linalg] Fix incorrect fusion with reshape ops by linearization.
Fusion of reshape ops by linearization incorrectly inverted the
indexing map before linearizing dimensions. This leads to incorrect
indexing maps used in the fused operation.

Differential Revision: https://reviews.llvm.org/D117908
2022-01-25 11:42:58 -08:00
MaheshRavishankar e5a315f57a [mlir][Linalg] Disallow ops with index semantics in `PushExpandingReshape`.
This pattern is not written to handle operations with `linalg.index`
operations in its body, i.e. operations that have index semantics.

Differential Revision: https://reviews.llvm.org/D117856
2022-01-25 10:37:30 -08:00
Benjamin Kramer 2c8a77ab21 [mlir] Move duplicated BufferizableOpInterface::kBufferLayoutAttrName defs to a single place 2022-01-25 15:20:30 +01:00
Matthias Springer d581c94d6b [mlir][linalg][bufferize] Support tensor.from_elements
This is mostly a copy of the existing tensor.from_elements bufferization. Once TensorInterfaceImpl.cpp is moved to the tensor dialect, the existing rewrite pattern can be deleted.

Differential Revision: https://reviews.llvm.org/D117775
2022-01-25 22:19:59 +09:00
Matthias Springer 71bbb78b8f [mlir][linalg][bufferize] Support tensor.generate
This is mostly a copy of the existing tensor.generate bufferization. Once TensorInterfaceImpl.cpp is moved to the tensor dialect, the existing rewrite pattern can be deleted.

Differential Revision: https://reviews.llvm.org/D117770
2022-01-25 22:19:22 +09:00
Matthias Springer 694df0f0a8 [mlir][linalg][bufferize] Fix build
This fixes a linker error related to ModuleBufferization.cpp.

Differential Revision: https://reviews.llvm.org/D118127
2022-01-25 21:59:23 +09:00
Chuanqi Xu dbbe010908 [MLIR] [AsyncToLLVM] Use llvm.coro.align intrinsic
Use llvm.coro.align to align coroutine frame properly.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D117978
2022-01-25 19:28:25 +08:00
Nikita Popov 22487280dc [NFC] Remove more uses of PointerType::getElementType() (NFC)
Replace more uses which I missed in the first pass with
Type::getPointerElementType().
2022-01-25 10:13:53 +01:00
Lorenzo Chelini bca2d85153 [MLIR][Interfaces] Silence -Wparentheses warning (NFC)
warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
2022-01-25 09:02:49 +01:00
River Riddle 881ff4e4eb [mlir] Remove unnecessary dependency on Tensor from MemRef 2022-01-24 22:59:01 -08:00
Shraiysh Vaishay 320dc8c4df [mlir][OpenMP] Added omp.atomic.capture operation
This patch supports the atomic construct (capture) following section 2.17.7 of OpenMP 5.0 standard. Also added tests for the same.

Reviewed By: peixin, kiranchandramohan

Differential Revision: https://reviews.llvm.org/D115851
2022-01-25 12:25:54 +05:30
River Riddle 633f5badbf [mlir] Add more missing dependencies after D118062
These used to be covered transitively, but now need to be explicit.
2022-01-24 22:12:03 -08:00
Uday Bondhugula 8676e10f74 [MLIR] Improve doc for -mlir-print-local-scope and unhide
This is a pretty important debugging option to stay hidden. Also,
improve its cmd-line description; the current description gives no hint
that this is the one to use to have locations printed inline.
Out-of-line locations are also unproductive to work with in many cases
where the locations are actually compact, which is also why this option
should be more visible.  This revision doesn't change the default on it
though.

Reviewed By: rriddle, jpienaar

Differential Revision: https://reviews.llvm.org/D117186
2022-01-25 11:13:48 +05:30
River Riddle e697b97148 [mlir] Add more missing dependencies after D118062
These used to be covered transitively, but now need to be explicit.
2022-01-24 21:36:31 -08:00
River Riddle b827b6340b [mlir] Add missing dependencies after D118062
These used to be covered transitively, but now need to be explicit.
2022-01-24 21:31:37 -08:00
River Riddle 61b81e0f49 [mlir:MLIRAffineUtils] Add missing dependency on MLIRAffineAnalysis
This was missed in a70aa7bb0d.
2022-01-24 21:23:39 -08:00
Mehdi Amini e51a20e166 Fix python test to register all passes before using "normalize-memrefs"
The pass moved from mlir.transforms to the Memref dialect.
2022-01-25 05:15:42 +00:00
River Riddle 63b8018468 [mlir:LoopLikeInterface] Add missing dependency on SideEffectInterfaces
This was missed when moveLoopInvariantCode was added.
2022-01-24 21:13:31 -08:00
River Riddle 65e7cd13bb [mlir] Remove a bunch of unnecessary dialect dependencies
A lot of dialects have dependencies that are unnecessary, either because of copy/paste
of files when creating things or some other means. This commit cleans up a bunch of
the simple ones:

* Copy/Paste or missed during refactoring
Most of the dependencies cleaned up here look like copy/paste errors when creating
new dialects/transformations, or because the dependency wasn't removed during a
refactoring (e.g. when splitting the standard dialect).

* Unnecessary hard coding of constant operations in matchers
There are a few instances where a dialect had a dependency because it
was hardcoding checks for constant operations instead of using the better m_Constant
approach.

Differential Revision: https://reviews.llvm.org/D118062
2022-01-24 19:25:53 -08:00
River Riddle 88c1df64bd [mlir:ArmSVE][NFC] Remove dead code and unnecessary dependencies
Differential Revision: https://reviews.llvm.org/D117981
2022-01-24 19:25:53 -08:00
River Riddle a70aa7bb0d [mlir:Transforms] Move out the remaining non-dialect independent transforms and utilities
This has been a major TODO for a very long time, and is necessary for establishing a proper
dialect-free dependency layering for the Transforms library. Code was moved to effectively
two main locations:

* Affine/
There was quite a bit of affine dialect related code in Transforms/ do to historical reasons
(of a time way into MLIR's past). The following headers were moved to:
Transforms/LoopFusionUtils.h -> Dialect/Affine/LoopFusionUtils.h
Transforms/LoopUtils.h -> Dialect/Affine/LoopUtils.h
Transforms/Utils.h -> Dialect/Affine/Utils.h

The following transforms were also moved:
AffineLoopFusion, AffinePipelineDataTransfer, LoopCoalescing

* SCF/
Only one SCF pass was in Transforms/ (likely accidentally placed here): ParallelLoopCollapsing
The SCF specific utilities in LoopUtils have been moved to SCF/Utils.h

* Misc:
mlir::moveLoopInvariantCode was also moved to LoopLikeInterface.h given
that it is a simple utility defined in terms of LoopLikeOpInterface.

Differential Revision: https://reviews.llvm.org/D117848
2022-01-24 19:25:53 -08:00
River Riddle 2e2c0738e8 [mlir:Transforms] Move NormalizeMemRefs to MemRef/Transforms/
Transforms/  should only contain transformations that are dialect-independent and
this pass interacts with MemRef operations (making it a better fit for living in that
dialect).

Differential Revision: https://reviews.llvm.org/D117841
2022-01-24 19:25:53 -08:00
River Riddle 0e9a4a3b65 [mlir] Move the Buffer related source files out of Transforms/
Transforms/ should only contain dialect-independent transformations,
and these files are a much better fit for the bufferization dialect anyways.

Differential Revision: https://reviews.llvm.org/D117839
2022-01-24 19:25:52 -08:00
harsh e01e4c9115 Fix bugs in GPUToNVVM lowering
The current lowering from GPU to NVVM does
not correctly handle the following cases when
lowering the gpu shuffle op.

1. When the active width is set to 32 (all lanes),
then the current approach computes (1 << 32) -1 which
results in poison values in the LLVM IR. We fix this by
defining the active mask as (-1) >> (32 - width).

2. In the case of shuffle up, the computation of the third
operand c has to be different from the other 3 modes due to
the op definition in the ISA reference.
(https://docs.nvidia.com/cuda/parallel-thread-execution/index.html)
Specifically, the predicate value is computed as j >= maxLane
for up and j <= maxLane for all other modes. We fix this by
computing maskAndClamp as 32 - width for this mode.

TEST: We modify the existing test and add more checks for the up mode.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D118086
2022-01-25 03:24:14 +00:00
Mehdi Amini ff8f7904d1 Remove null check after dereferencing the pointer (NFC)
Flagged by Coverity
2022-01-25 02:08:16 +00:00