Commit graph

10824 commits

Author SHA1 Message Date
Alex Zinenko 0be38d4f32 [mlir][ods] Add description to Attr and ensure doc generation
Add the description textual field to the Attr ODS class to mirror an
identical field in the Type ODS class. Add support for generating
documentation for attribute constraints defined using this field. This
ensures mlir-tblgen produces at least some documentation for dialects
that only define attribute constraints, such as DLTI.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D123024
2022-04-05 10:40:15 +02:00
Mehdi Amini d2ca2b94fd Apply clang-tidy fixes for readability-redundant-control-flow in FuncToLLVM.cpp (NFC) 2022-04-05 08:19:33 +00:00
Alexander Belyaev 64f659bee6 [mlir] Rewrite canonicalization of collapse(expand) and expand(collapse).
Differential Revision: https://reviews.llvm.org/D122666
2022-04-05 10:03:07 +02:00
Adrian Kuegel 72fe439a4e [mlir] Fix 1 ClangTidyPerformance finding (NFC) 2022-04-05 09:29:35 +02:00
wren romano 72ec2f7639 [mlir][sparse] Factoring out finalizeSegment and (generic) appendIndex
This change introduces two new methods: `finalizeSegment` and `appendIndex`; and removes three old methods: `endDim`, `appendCurrentPointer`, `appendIndex`.  The two new methods better encapsulate their algorithms, thus allowing to remove repetitious code in several other places.

Depends On D122435

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D122625
2022-04-04 19:11:31 -07:00
Arjun P b238c252e8 Revert "[MLIR][Presburger] IntegerPolyhedron: add support for symbolic integer lexmin"
This reverts commit da92f92621.
2022-04-05 00:31:17 +01:00
Arjun P da92f92621 [MLIR][Presburger] IntegerPolyhedron: add support for symbolic integer lexmin
Add support for computing the symbolic integer lexmin of a polyhedron.
This finds, for every assignment to the symbols, the lexicographically
minimum value attained by the dimensions. For example, the symbolic lexmin
of the set

`(x, y)[a, b, c] : (a <= x, b <= x, x <= c)`

can be written as

```
x = a if b <= a, a <= c
x = b if a <  b, b <= c
```

This also finds the set of assignments to the symbols that make the lexmin unbounded.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D122985
2022-04-05 00:24:57 +01:00
River Riddle 1269f96d2e [mlir] Add MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID to SerializeToCubinPass
This pass is defined in an anonymous namespace and requires an explicit TypeID
2022-04-04 14:28:10 -07:00
Lei Zhang f1a7e508a5 [mlir][spirv] Check nullptr before usage to fix crash
Reviewed By: mravishankar, hanchung

Differential Revision: https://reviews.llvm.org/D123035
2022-04-04 17:20:00 -04:00
River Riddle 5e50dd048e [mlir] Rework the implementation of TypeID
This commit restructures how TypeID is implemented to ideally avoid
the current problems related to shared libraries. This is done by changing
the "implicit" fallback path to use the name of the type, instead of using
a static template variable (which breaks shared libraries). The major downside to this
is that it adds some additional initialization costs for the implicit path. Given the
use of type names for uniqueness in the fallback, we also no longer allow types
defined in anonymous namespaces to have an implicit TypeID. To simplify defining
an ID for these classes, a new `MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID` macro
was added to allow for explicitly defining a TypeID directly on an internal class.

To help identify when types are using the fallback, `-debug-only=typeid` can be
used to log which types are using implicit ids.

This change generally only requires changes to the test passes, which are all defined
in anonymous namespaces, and thus can't use the fallback any longer.

Differential Revision: https://reviews.llvm.org/D122775
2022-04-04 13:52:26 -07:00
wren romano 3bf2ba3b9a [mlir][sparse] Simplifying code in expInsert
Just some minor cleanup

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D122934
2022-04-04 12:53:42 -07:00
Rob Suderman 126e7eaf0d [tosa] Add option to disable tosa.apply_scale lowering in TosaToStandard
Apply scale should be optionally disabled when lowering via TosaToStandard.
In most cases it should persist until the lowering to specific backend.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D122948
2022-04-04 12:22:12 -07:00
Daniel Resnick e394c4e5d9 [mlir][capi] Fix leak in test 2022-04-04 12:26:13 -06:00
Mehdi Amini dacb2713c4 Apply clang-tidy fixes for llvm-qualified-auto in FuncToLLVM.cpp (NFC) 2022-04-04 18:18:10 +00:00
antonio-cortes-perez c2a8a104ec [MLIR][NFC] Remove unnecessary cast.
I was reading this post:
https://www.fluentcpp.com/2017/05/19/crtp-helper/

And I noticed that most likely this cast is not needed.
Unless it is needed by some compiler versions.
I tested it with:
cmake --build . --target check-mlir

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D121555
2022-04-04 09:46:24 -07:00
Benjamin Kramer 4ae24d9fd9 [mlir][capi] Unbreak Interfaces CAPI after 2387fadea3
No idea why check-mlir doesn't build this.
2022-04-04 18:52:11 +02:00
Siddharth Bhat 96039b73d8 [MLIR] Add nested symbols into LangRef
Add documentation into the LangRef for parsing nested symbols.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D122977
2022-04-04 22:06:19 +05:30
Groverkss aebd3f0799 Revert "[MLIR] Add nested symbols into LangRef"
Reverted because commit pushed with wrong author information

This reverts commit b4865dd67f.
2022-04-04 22:01:06 +05:30
Siddharth Bhat 94b372e725 [MLIR] Add booleans to dense element list in LangRef
Add boolean values as a dense element, as tested in the MLIR parser:

```
  // CHECK: "splatBoolTensor"() {bar = dense<false> : tensor<i1>} : () -> ()
  "splatBoolTensor"(){bar = dense<false> : tensor<i1>} : () -> ()
```

43d758b142/mlir/test/IR/parser.mlir (L630-L631)

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D122978
2022-04-04 21:59:44 +05:30
Groverkss b4865dd67f [MLIR] Add nested symbols into LangRef
Add documentation into the LangRef for parsing nested symbols.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D122977
2022-04-04 21:59:44 +05:30
Daniel Resnick 2387fadea3 [mlir][capi] Add external pass creation to MLIR C-API
Adds the ability to create external passes using the C-API. This allows passes
to be written in C or languages that use the C-bindings.

Differential Revision: https://reviews.llvm.org/D121866
2022-04-04 10:27:11 -06:00
Sergei Grechanik b08ede4374 [MLIR] Fix MLIR vim syntax file
This commit fixes several things in the MLIR vim syntax file:
- Spell checking is now on by default only in comments.
- '#' now starts an identifier instead of starting an outline attribute
  declaration, which fixes coloring the rest of the line as a
  preprocessor directive when there is a '#' in the middle.
- '!' and '^' -prefixed identifiers are now colored as types
  and labels.

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D122626
2022-04-04 09:02:32 -07:00
PeixinQiao 706dec3e47 [mlir] Fix the build error in OpenMPToLLVMIRTranslation.cpp
Fix the build error with "-Werror,-Wcovered-switch-default".

Reviewed By: hpmorgan

Differential Revision: https://reviews.llvm.org/D123018
2022-04-04 19:46:16 +08:00
Groverkss bab2a4f2fb [MLIR][Presburger] Use PresburgerSpace in SetCoalescer
This patch changes the implementation of SetCoalescer to use PresburgerSpace
instead of reimplementing parts of PresburgerSpace.

Reviewed By: arjunp

Differential Revision: https://reviews.llvm.org/D122984
2022-04-03 04:06:47 +05:30
Groverkss 1483fb33b3 [MLIR][Presburger][NFC] Rename getCompatibleSpace to getSpaceWithoutLocals
Reviewed By: arjunp

Differential Revision: https://reviews.llvm.org/D122973
2022-04-02 23:39:57 +05:30
Groverkss 86f255360c [MLIR][Presburger] Make constructors from PresburgerSpace explicit
This patch makes constructors of IntegerRelation, IntegerPolyhedron,
PresburgerRelation, PresburgerSet from PresburgerSpace explicit. This
prevents bugs like:

```
void fun(IntegerRelation a, IntegerRelation b) {
  IntegerPolyhedron c = a.intersect(b);
}
```

Here, `a.intersect(b)` will return `IntegerRelation`, which will be implicitly
converted to `PresburgerSpace` and will use the `PresburgerSpace` constructor
for IntegerPolyhedron. Leading to loss of any constraints in the intersection
of `a` and `b`. After this patch, this will give a compile error.

Reviewed By: arjunp

Differential Revision: https://reviews.llvm.org/D122972
2022-04-02 18:14:38 +05:30
Arjun P fbeb0db54f [MLIR][Presburger] LexSimplex: support is{Redundant,Separate}Inequality
Add integer-exact checks for inequalities being separate and redundant in LexSimplex.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D122921
2022-04-02 12:31:17 +01:00
Arjun P 698484549a [MLIR][Presburger] Make the SimplexBase constructor protected
This is not supposed to be instantiated directly anyway.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D122923
2022-04-02 12:30:23 +01:00
River Riddle 0d8df98035 [mlir] Allow for using OpPassManager in pass options
This significantly simplifies the boilerplate necessary for passes
to define nested pass pipelines.

Differential Revision: https://reviews.llvm.org/D122880
2022-04-02 00:45:11 -07:00
River Riddle 6edef13569 [mlir:PassOption] Rework ListOption parsing and add support for std::vector/SmallVector options
ListOption currently uses llvm:🆑:list under the hood, but the usages
of ListOption are generally a tad different from llvm:🆑:list. This
commit codifies this by making ListOption implicitly comma separated,
and removes the explicit flag set for all of the current list options.
The new parsing for comma separation of ListOption also adds in support
for skipping over delimited sub-ranges (i.e. {}, [], (), "", ''). This
more easily supports nested options that use those as part of the
format, and this constraint (balanced delimiters) is already codified
in the syntax of pass pipelines.

See https://discourse.llvm.org/t/list-of-lists-pass-option/5950 for
related discussion

Differential Revision: https://reviews.llvm.org/D122879
2022-04-02 00:45:11 -07:00
jacquesguan bc37077947 [mlir][Vector] Add constant folder for extractelement.
This revision adds constant folder for vector.extractelement.

Differential Revision: https://reviews.llvm.org/D122886
2022-04-02 11:10:42 +08:00
jacquesguan 262823612d [mlir][Vector] Add constant folder for insertelement.
This revision adds constant folder for vector.insertelement.

Differential Revision: https://reviews.llvm.org/D122721
2022-04-02 10:20:19 +08:00
Jacques Pienaar ad38f409f9 [mlir] Switch debugString helper to << operator
Supports more cases.
2022-04-01 16:33:35 -07:00
Lei Zhang a480d75fe4 [mlir][vector] Fold transpose(broadcast(<scalar>))
For such cases, the transpose op can be elided.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D122903
2022-04-01 14:51:36 -04:00
wren romano 63bdcaf92a [mlir][sparse] Moving delete coo into codegen instead of runtime library
Prior to this change there were a number of places where the allocation and deallocation of SparseTensorCOO objects were not cleanly paired, leading to inconsistencies regarding whether each function released its tensor/coo arguments or not, as well as making it easy to run afoul of memory leaks, use-after-free, or double-free errors.  This change cleans up the codegen vs runtime boundary to resolve those issues.  Now, the only time the runtime library frees an object is either (a) because it's a function explicitly designed to do so, or (b) because the allocated object is entirely local to the function and would be a memory leak if not released.  Thus, now the codegen takes complete responsibility for releasing any objects it caused to be allocated.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D122435
2022-04-01 11:08:52 -07:00
Lei Zhang 57b101bdec [mlir][vector] Handle scalars in extract_strided_slice(broadcast)
For such cases we cannot generate extract_strided_slice ops.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D122902
2022-04-01 12:07:47 -04:00
Lei Zhang 533ec929f6 [mlir][spirv] Add pattern to lower math.copysign
This follows the logic:
https://git.musl-libc.org/cgit/musl/tree/src/math/copysignf.c

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D122910
2022-04-01 12:06:47 -04:00
Matthias Springer 73c0333dee [mlir][tensor][bufferize] Support 0-d collapse_shape with offset
Differential Revision: https://reviews.llvm.org/D122901
2022-04-01 22:30:37 +09:00
Groverkss de70ff10e4 [MLIR][Presburger][NFC] Use "disjunct" to refer to disjuncts in PresburgerRelation
This patch modifies the name "integerRelations" and "relation" to refer to the
disjuncts in PresburgerRelation to "disjunct(s)".  This is done to be
consistent with the rest of the interface.

Reviewed By: arjunp

Differential Revision: https://reviews.llvm.org/D122892
2022-04-01 17:38:30 +05:30
Arjun P 31cb99959f [MLIR][Presburger] subtract: fix bug when an input set has duplicate divisions
Previously, when an input set had a duplicate division, the duplicates might
be removed by a call to mergeLocalIds due to being detected as being duplicate
for the first time. The subtraction implementation cannot handle existing
locals being removed, so this would lead to unexpected behaviour. Resolve this
by removing all the duplicates up front.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D122826
2022-04-01 12:38:45 +01:00
Arjun P acb378e21c [MLIR][Presburger] Factor out some functionality from LexSimplex into a LexSimplexBase
LexSimplex cannot be made to support symbols for symbolic lexmin; this requires
a second class. In preparation for upstreaming support for symbolic lexmin,
keep the part of LexSimplex that are specific to non-symbolic lexmin in LexSimplex
and move the parts that are required to a common class LexSimplexBase for both to
inherit from.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D122828
2022-04-01 11:54:26 +01:00
Groverkss a5a598be44 [MLIR][Presburger] Use PresburgerSpace in constructors
This patch modifies IntegerPolyhedron, IntegerRelation, PresburgerRelation,
PresburgerSet, PWMAFunction, constructors to take PresburgerSpace instead of
dimensions. This allows information present in PresburgerSpace to be carried
better and allows for a general interface.

Reviewed By: arjunp

Differential Revision: https://reviews.llvm.org/D122842
2022-04-01 15:07:26 +05:30
Peixin-Qiao 3e7415a0ff [OMPIRBuilder] Support ordered clause specified without parameter
This patch supports ordered clause specified without parameter in
worksharing-loop directive in the OpenMPIRBuilder and lowering MLIR to
LLVM IR.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D114940
2022-04-01 16:17:29 +08:00
Mehdi Amini 83e3c6a717 Fix MLIR test pass
Inadvertently removed `populateWithGenerated` while testing native
patterns.
2022-04-01 06:37:18 +00:00
Mehdi Amini 43f0d5f934 Add a test case for applyPatternsAndFoldGreedily to support the revert of 59bbc7a08
This shows that pushing constant to the right in a commutative op leads
to `applyPatternsAndFoldGreedily` to converge without applying all the
patterns.

Differential Revision: https://reviews.llvm.org/D122870
2022-04-01 06:17:07 +00:00
Mehdi Amini ba43d6f85c Revert "[GreedPatternRewriter] Preprocess constants while building worklist when not processing top down"
This reverts commit 59bbc7a085.

This exposes an issue breaking the contract of
`applyPatternsAndFoldGreedily` where we "converge" without applying
remaining patterns.
2022-04-01 06:16:55 +00:00
River Riddle 59bbc7a085 [GreedPatternRewriter] Preprocess constants while building worklist when not processing top down
This avoids accidentally reversing the order of constants during successive
application, e.g. when running the canonicalizer. This helps reduce the number
of iterations, and also avoids unnecessary changes to input IR.

Fixes #51892

Differential Revision: https://reviews.llvm.org/D122692
2022-03-31 12:08:55 -07:00
Alex Zinenko 3a4ada6991 Revert "Added an empty __init__.py file to the MLIR Python bindings"
This reverts commit b50893db52.

Post-commit review pointed out that adding this file will require the
entire Python tree (including out-of-tree projects) to come from the
same directory, which might be problematic in non-default installations.
Reverting pending further discussion.
2022-03-31 20:03:52 +02:00
Okwan Kwon 65bdeddb1e [mlir] Bubble up tensor.extract_slice above linalg operation
Bubble up extract_slice above Linalg operation.

A sequence of operations

    %0 = linalg.<op> ... arg0, arg1, ...
    %1 = tensor.extract_slice %0 ...

can be replaced with

    %0 = tensor.extract_slice %arg0
    %1 = tensor.extract_slice %arg1
    %2 = linalg.<op> ... %0, %1, ...

This results in the reduce computation of the linalg operation.

The implementation uses the tiling utility functions. One difference
from the tiling process is that we don't need to insert the checking
code for the out-of-bound accesses. The use of the slice itself
represents that the code writer is sure about the boundary condition.
To avoid adding the boundary condtion check code, `omitPartialTileCheck`
is introduced for the tiling utility functions.

Differential Revision: https://reviews.llvm.org/D122437
2022-03-31 16:48:38 +00:00
Groverkss 152e501d87 [MLIR][Presburger] Carry IdKind information in LinearTransform::applyTo
This patch fixes a bug in LinearTransform::applyTo where it did not carry the
IdKind information, and instead treated every id as IdKind::Domain.

Reviewed By: arjunp

Differential Revision: https://reviews.llvm.org/D122823
2022-03-31 20:42:50 +05:30