Commit Graph

10135 Commits

Author SHA1 Message Date
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