Commit Graph

9088 Commits

Author SHA1 Message Date
Jacques Pienaar 8619212b94 [mlir] Flip math dialect to _Both prefixed form (NFC)
See https://llvm.discourse.group/t/psa-ods-generated-accessors-will-change-to-have-a-get-prefix-update-you-apis/4476
2021-11-09 09:30:37 -08:00
Denys Shabalin 48d1f099d4 [mlir] Add nano precision clock to execution engine
Reviewed By: ftynse, nicolasvasilache

Differential Revision: https://reviews.llvm.org/D113476
2021-11-09 14:32:36 +01:00
Groverkss 6706a4720f [MLIR][NFC] FlatAffineConstraints: Refactor division representation computation
This patch factors out division representation computation from upper-lower bound
inequalities to a separate function. This is done to improve readability and reuse.

This patch is marked NFC since the only change is factoring out existing code
to a separate function.

Reviewed By: grosser

Differential Revision: https://reviews.llvm.org/D113463
2021-11-09 14:08:15 +05:30
River Riddle 937e40a8cf [mlir] Remove the non-templated DenseElementsAttr::getSplatValue
This predates the templated variant, and has been simply forwarding
to getSplatValue<Attribute> for some time. Removing this makes the
API a bit more uniform, and also helps prevent users from thinking
it is "cheap".
2021-11-09 01:40:40 +00:00
River Riddle ae40d62541 [mlir] Refactor ElementsAttr's value access API
There are several aspects of the API that either aren't easy to use, or are
deceptively easy to do the wrong thing. The main change of this commit
is to remove all of the `getValue<T>`/`getFlatValue<T>` from ElementsAttr
and instead provide operator[] methods on the ranges returned by
`getValues<T>`. This provides a much more convenient API for the value
ranges. It also removes the easy-to-be-inefficient nature of
getValue/getFlatValue, which under the hood would construct a new range for
the type `T`. Constructing a range is not necessarily cheap in all cases, and
could lead to very poor performance if used within a loop; i.e. if you were to
naively write something like:

```
DenseElementsAttr attr = ...;
for (int i = 0; i < size; ++i) {
  // We are internally rebuilding the APFloat value range on each iteration!!
  APFloat it = attr.getFlatValue<APFloat>(i);
}
```

Differential Revision: https://reviews.llvm.org/D113229
2021-11-09 00:15:08 +00:00
Chia-hung Duan 2d99c815d7 [mlir-tblgen] Support `either` in Tablegen DRR.
Add a new directive `either` to specify the operands can be matched in either order

Reviewed By: jpienaar, Mogball

Differential Revision: https://reviews.llvm.org/D110666
2021-11-08 23:16:03 +00:00
Marius Brehler 2494e9c592 [mlir][docs] Unify style (nfc) 2021-11-08 22:43:05 +00:00
Chia-hung Duan f3798ad5fa Static verifier for type/attribute in DRR
Generate static function for matching the type/attribute to reduce the
memory footprint.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D110199
2021-11-08 21:34:17 +00:00
Mogball 254ecfbc40 [mlir][ods] fix c++11 build 2021-11-08 20:40:13 +00:00
Suraj Sudhir 82568021dd [mlir][tosa] Spec v0.23 updates
Add pad_const field to tosa.pad.
Add builders to enable optional construction of pad_const in pad op.
Update documentation of tosa.clamp to match spec wording.

Signed-off-by: Suraj Sudhir <suraj.sudhir@arm.com>

Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D113322
2021-11-08 10:13:54 -08:00
Jeff Niu 9a2fdc369d [MLIR] Attribute and type formats in ODS
Declarative attribute and type formats with assembly formats. Define an
`assemblyFormat` field in attribute and type defs with a `mnemonic` to
generate a parser and printer.

```tablegen
def MyAttr : AttrDef<MyDialect, "MyAttr"> {
  let parameters = (ins "int64_t":$count, "AffineMap":$map);
  let mnemonic = "my_attr";
  let assemblyFormat = "`<` $count `,` $map `>`";
}
```

Use `struct` to define a comma-separated list of key-value pairs:

```tablegen
def MyType : TypeDef<MyDialect, "MyType"> {
  let parameters = (ins "int":$one, "int":$two, "int":$three);
  let mnemonic = "my_attr";
  let assemblyFormat = "`<` $three `:` struct($one, $two) `>`";
}
```

Use `struct(*)` to capture all parameters.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D111594
2021-11-08 17:38:28 +00:00
Lei Zhang 56ada0f80d [mlir][vector] Use dyn_cast instead of cast in patterns
This avoids crashes when the pattern is applied to ops with
tensor semantics.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D113415
2021-11-08 12:34:14 -05:00
Quinn Pham c3b15b71ce [NFC] Inclusive Language: change master to main for .chm files
[NFC] As part of using inclusive language within the llvm project,
this patch replaces master with main when referring to `.chm` files.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D113299
2021-11-08 08:23:04 -06:00
Tobias Gysi 1726c956ae [mlir][linalg] Improve hoist padding buffer size computation.
Adapt the Fourier Motzkin elimination to take into account affine computations happening outside of the cloned loop nest.

Depends On D112713

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D112838
2021-11-08 12:02:57 +00:00
Tobias Gysi 9fbcad3298 [mlir][linalg] Improve the padding packing loop computation.
The revision updates the packing loop search in hoist padding. Instead of considering all loops in the backward slice, we now compute a separate backward slice containing the index computations only. This modification ensures we do not add packing loops that are not used to index the packed buffer due to spurious dependencies. One instance where such spurious dependencies can appear is the extract slice operation introduced between the tile loops of a double tiling.

Depends On D112412

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D112713
2021-11-08 10:20:33 +00:00
Shraiysh Vaishay 19a7e4729d [MLIR][OpenMP] Added omp.sections and omp.section
Added omp.sections and omp.section operation according to the
section 2.8.1 of OpenMP Standard 5.0.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D110844
2021-11-06 19:27:35 +05:30
Kazu Hirata ca1a8be06b [Transforms] Fix a warning
This patch fixes:

  mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp:124:3:
  error: default label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

by removing the default case.
2021-11-05 19:30:14 -07:00
wren romano 845561ec9d [mlir][sparse] Factoring magic numbers into a header
Addresses https://bugs.llvm.org/show_bug.cgi?id=52303

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D112962
2021-11-05 15:59:16 -07:00
Aart Bik 38c366e467 [mlir][sparse] run more integration tests with and without SIMD
Reviewed By: wrengr

Differential Revision: https://reviews.llvm.org/D113205
2021-11-05 12:51:38 -07:00
River Riddle 4070f305f9 [mlir][DialectConversion] Legalize all live argument conversions
Previously we didn't materialize conversions for arguments in certain
cases as the implicit type propagation was being heavily relied on
by many patterns. Now that those patterns have been fixed to
properly handle type conversions, we can drop the special behavior.

Differential Revision: https://reviews.llvm.org/D113233
2021-11-05 18:43:56 +00:00
Deepak Panickal 97c899f3c5 [mlir] Add callback to provide a pass pipeline to MlirOptMain
The callback can be used to provide a default pass pipeline.

Reviewed By: mehdi_amini, rriddle

Differential Revision: https://reviews.llvm.org/D113144
2021-11-05 17:46:35 +00:00
Aart Bik 2f0ee17017 [mlir][sparse] test for SIMD reduction chaining in consecutive vector loops
Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D113197
2021-11-05 10:14:17 -07:00
Quinn Pham c71fbdd87b [NFC] Inclusive language: Remove instances of master in URLs
[NFC] This patch fixes URLs containing "master". Old URLs were either broken or
redirecting to the new URL.

Reviewed By: #libc, ldionne, mehdi_amini

Differential Revision: https://reviews.llvm.org/D113186
2021-11-05 08:48:41 -05:00
Alex Zinenko 6981e5ec91 [mlir][python] fix constructor generation for optional operands in presence of segment attribute
The ODS-based Python op bindings generator has been generating incorrect
specification of the operand segment in presence if both optional and variadic
operand groups: optional groups were treated as variadic whereas they require
separate treatement. Make sure it is the case. Also harden the tests around
generated op constructors as they could hitherto accept the code for both
optional and variadic arguments.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D113259
2021-11-05 12:40:27 +01:00
Matthias Springer 020ca1747d [mlir][linalg][bufferize] Move bufferizesToAliasOnly to extraClassDecls
By doing so, the method can no longer be reimplemented.

Differential Revision: https://reviews.llvm.org/D113248
2021-11-05 18:08:43 +09:00
Christian Sigg fce529fc6e Fix `insertFunctionArguments()` block argument order.
Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D113171
2021-11-05 10:08:20 +01:00
Matthias Springer 95e62eb430 [mlir][linalg][bufferize] Separate pass from ComprehensiveBufferize
This commit separates the bufferization from the bufferization pass in Linalg. This allows other dialects to use ComprehensiveBufferize more easily.

This commit mainly moves files to a new directory and adds a new build target.

Differential Revision: https://reviews.llvm.org/D112989
2021-11-05 13:56:39 +09:00
Matthias Springer ed1cbebafa [mlir][linalg][bufferize][NFC] Simplify AllocationCallbacks
AllocationCallbacks functions allocate/deallocate only. They no longer set the insertion point.

This is in preparation of decoupling ComprehensiveBufferize from the Linalg dialect.

Differential Revision: https://reviews.llvm.org/D112991
2021-11-05 11:56:06 +09:00
Matthias Springer 37317f5bd2 [mlir][linalg][bufferize] Decouple BufferizationAliasInfo
Move dialect-specific and analysis-specific function out of BufferizationAliasInfo. BufferizationAliasInfo's only job now is to keep track of aliases.

This is in preparation of futher decoupling ComprehensiveBufferize from various dialects.

Differential Revision: https://reviews.llvm.org/D112992
2021-11-05 11:41:00 +09:00
Matthias Springer c8f4005b0c [mlir][linalg][bufferize] Add isWritable to op interface
By default, OpResult buffers are writable. But there are ops (e.g., ConstantOp) for which this is not the case.

The purpose of this commit is to further decouple Comprehensive Bufferize from the Standard dialect.

Differential Revision: https://reviews.llvm.org/D112908
2021-11-05 11:31:22 +09:00
Matthias Springer 3f6c0fb2ff [mlir][linalg][bufferize] Add MemCpyFn to AllocationCallbacks struct
This in preparation of decoupling BufferizableOpInterface, Comprehensive Bufferize and dialects.

The goal of this CL is to make `getResultBuffer` (and other `bufferize` functions) independent of `LinalgOps`.

Differential Revision: https://reviews.llvm.org/D112907
2021-11-05 10:44:12 +09:00
Matthias Springer 9714444f1e [mlir][linalg][bufferize] Remove redundant methods from op interface
These two methods are redundant and removed:
* `bufferizesToAliasOnly`: If not `bufferizesToMemoryRead` and not `bufferizesToMemoryWrite` but `getAliasingOpResult` returns a non-null value, we know that this OpOperand is alias-only. This method now has a default implementation and does not have to be implemented.
* `getInplaceableOpResult`: The analysis does not differentiate between "inplaceable" and "aliasing". The only thing that matters is whether or not OpOperand and OpResult are aliasing. That is the key property that makes buffer copies necessary.

Differential Revision: https://reviews.llvm.org/D112902
2021-11-05 09:44:10 +09:00
Aart Bik 7373cabcda [mlir][sparse] implement full reduction "scalarization" across loop nests
The earlier reduction "scalarization" was only applied to a chain of
*innermost* and *for* loops. This revision generalizes this to any
nesting of for- and while-loops. This implies that reductions can be
implemented with a lot less load and store operations. The chaining
is implemented with a forest of yield statements (but not as bad as
when we would also include the while-induction).

Fixes https://bugs.llvm.org/show_bug.cgi?id=52311

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D113078
2021-11-04 17:38:47 -07:00
not-jenni 07a029c057 Canonicalization for add to no-op if one of the inputs is zero
Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D113207
2021-11-04 16:52:47 -07:00
Mogball 2125eb3446 [mlir][core] Slightly improved attribute lookup
- String binary search does 1 less string comparison
- Identifier linear scan on large attribute list is switched to string binary search

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D112970
2021-11-04 21:48:58 +00:00
Mogball 8129b04b8a [mlir][ods] Op::verify should not call OpAdaptor::verify
OpAdaptor::verify performs string lookups on an attribute dictionary. By
calling OpAdaptor::verify, Op::verify is not able to use cached attribute
identifiers for faster lookups.

Reviewed By: jpienaar, rriddle

Differential Revision: https://reviews.llvm.org/D113039
2021-11-04 19:12:55 +00:00
Chia-hung Duan 64ce74a6c8 [mlir] Handle StringAttr in SparseElementsAttr::getZeroAttr.
Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D111203
2021-11-04 18:18:20 +00:00
Aart Bik 4aa9b39824 [mlir][sparse] reject sparsity annotation in "scalar" tensors
Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D113152
2021-11-04 09:49:05 -07:00
Tobias Gysi 29c31cb79b [mlir][linalg] Add support for transitive fusion.
Extend fusion on tensors to fuse producers greedily.

Reviewed By: nicolasvasilache, hanchung

Differential Revision: https://reviews.llvm.org/D110262
2021-11-04 16:25:06 +00:00
Markus Böck 5f32a851fb [mlir] Fix typos in comments 2021-11-04 10:59:44 +01:00
Matthias Springer bb83520dce [mlir][linalg][bufferize] Generalize InitTensorOp elimination
This allows for external users of Comprehensive Bufferize to specify their own InitTensorOp elimination procedures.

Differential Revision: https://reviews.llvm.org/D112686
2021-11-04 13:53:12 +09:00
Matthias Springer 9c137f7668 [mlir][linalg][bufferize] Fix typo in function name
Differential Revision: https://reviews.llvm.org/D113162
2021-11-04 10:48:39 +09:00
Jacques Pienaar a7fc39f213 [mlir] Use _odsPrinter for printer name in generated code
The generated name should not be load bearing, so this should be a NFC change.

Differential Revision: https://reviews.llvm.org/D113149
2021-11-03 15:34:13 -07:00
Mogball 6da63573e4 [mlir] fix Debug unittests
Flag NDEBUG needed to be changed to LLVM_ENABLE_ABI_BREAKING_CHECKS
2021-11-03 21:34:36 +00:00
River Riddle 7f312f6d79 [mlir] Avoid folding in OpBuilder::tryFold when types change
This was missed when tightening fold restrictions in https://reviews.llvm.org/D95991.

Differential Revision: https://reviews.llvm.org/D113138
2021-11-03 20:35:46 +00:00
River Riddle a039113446 [mlir] Move the Operation OperandStorage to the first trailing object
The main benefits of this change are faster access to operands
(no need to compute the offset, as it is now right after the
operation), simpler code(no need to manage a lot of the "is the
operand storage trailing" logic we had to before). The major
downside to this though, is that operand holding operations now
grow in size by 1 word (as no matter how we do this change, there
will need to be some additional book keeping).

Differential Revision: https://reviews.llvm.org/D111695
2021-11-03 18:34:31 +00:00
Markus Böck 2e02d2a62f [mlir] Change ABI breaking use of NDEBUG to LLVM_ENABLE_ABI_BREAKING_CHECKS in DebugActions.h
A quick grep for NDEBUG in MLIR revealed a use in DebugActions.h that breaks ABI. This patch changes the use of NDEBUG to LLVM_ENABLE_ABI_BREAKING_CHECKS which has the advantage of being independent of whether clients build their own app in debug or release as it is purely dependant on how MLIR itself was built.

Differential Revision: https://reviews.llvm.org/D113088
2021-11-03 19:03:04 +01:00
Cullen Rhodes 6c5a897c44 [mlir][nvvm] NFC: Fix unused template arg tablegen warning
Identified in D109359.
2021-11-03 11:55:06 +00:00
Butygin 1cb13fddb9 [mlir] spirv: Add some atomic ops
Differential Revision: https://reviews.llvm.org/D112812
2021-11-03 14:47:12 +03:00
Alex Zinenko 34f72d9125 [mlir][python] expose the shape property of shaped types
This has been missing in the original definition of shaped types.

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D113025
2021-11-03 10:49:12 +01:00