Commit Graph

12284 Commits

Author SHA1 Message Date
Jeff Niu bca889524a [mlir][python] add a todo to replace throw in dense array iterator 2022-08-12 23:35:38 -04:00
Jeff Niu 96da738dc5 [mlir] Remove colon from empty dense array syntax
E.g. `array<i32:>` -> `array<i32>`

Reviewed By: rriddle, jpienaar

Differential Revision: https://reviews.llvm.org/D131823
2022-08-12 22:36:54 -04:00
Jeff Niu e35ca70eb3 [mlir][ods] Rename Confined and AllAttrConstraintsOf
Confined -> ConfinedAttr
AllAttrConstraintsOf -> AllOfAttr

To be in line with ConfinedType and AllOfType.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D131822
2022-08-12 22:36:17 -04:00
Kazu Hirata 5c4674d67b [mlir] Deprecate OptionalParseResult::{hasValue,getValue}
This patch deprecates hasValue and getValue for consistency with
std::optional and llvm::Optional.  Note that I've migrated all known
uses of them to has_value and value, respectively.

Differential Revision: https://reviews.llvm.org/D131366
2022-08-12 19:19:24 -07:00
Kazu Hirata 7082e1506d [mlir] Use has_value instead of hasValue (NFC) 2022-08-12 19:19:23 -07:00
Jeff Niu 60d2769239 [mlir][ods] OpFormat: ensure that regions don't follow `attr-dict`
An optional attribute dictionary before a region in an assembly format
is a potential format ambiguity because they both start with `{`.

Fixes #53077

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D131636
2022-08-12 21:00:25 -04:00
Jeff Niu a2ad3ec7ac [mlir][ods] Support string literals in `custom` directives
This patch adds support for string literals as `custom` directive
arguments. This can be useful for re-using custom parsers and printers
when arguments have a known value. For example:

```
ParseResult parseTypedAttr(AsmParser &parser, Attribute &attr, Type type) {
  return parser.parseAttribute(attr, type);
}

void printTypedAttr(AsmPrinter &printer, Attribute attr, Type type) {
  return parser.printAttributeWithoutType(attr);
}
```

And in TableGen:

```
def FooOp : ... {
  let arguments = (ins AnyAttr:$a);
  let assemblyFormat = [{ custom<TypedAttr>($a, "$_builder.getI1Type()")
                          attr-dict }];
}

def BarOp : ... {
  let arguments = (ins AnyAttr:$a);
  let assemblyFormat = [{ custom<TypedAttr>($a, "$_builder.getIndexType()")
                          attr-dict }];
}
```

Instead of writing two separate sets of custom parsers and printers.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D131603
2022-08-12 20:55:11 -04:00
Jeff Niu 58a47508f0 (Reland) [mlir] Switch segment size attributes to DenseI32ArrayAttr
This reland includes changes to the Python bindings.

Switch variadic operand and result segment size attributes to use the
dense i32 array. Dense integer arrays were introduced primarily to
represent index lists. They are a better fit for segment sizes than
dense elements attrs.

Depends on D131801

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D131803
2022-08-12 19:44:52 -04:00
Jeff Niu 619fd8c2ab [mlir][python] Add python bindings for DenseArrayAttr
This patch adds python bindings for the dense array variants.

Fixes #56975

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131801
2022-08-12 19:44:49 -04:00
Eric Kunze 9dec80be72 [MLIR][TOSA] Remove ReluN operator from TOSA dialect
ReluN has been removed from the TOSA specification. It can be replaced
in all instances with Clamp(0,N)

Signed-off-by: Eric Kunze <eric.kunze@arm.com>

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D128683
2022-08-12 16:00:11 -07:00
Jeff Niu 8a3481b958 [mlir] Add AllOfType and ConfinedType constraints
`AllOfType` is a type constraint that satisfies all given type
constraints and `ConfinedType` is a type that satisfies additional
predicates. These shorthands simplify type constraint definition mostly
by removing the need to deal with `myType.predicate` manipulation.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D131788
2022-08-12 16:25:36 -04:00
Jacques Pienaar d6f2e32fc1 [mlir] Flip Tensor dialect and ViewLike (NFC)
Also requires updating view like interface to use prefixed form.

Differential Revision: https://reviews.llvm.org/D131361
2022-08-12 12:41:32 -07:00
Frederik Gossen 2c3ca3b684 [MLIR] Add utility function to create values for all dimensions of a tensor value
This is a variant of the already provided `createDynamicDimValues` helper.

Differential Revision: https://reviews.llvm.org/D131798
2022-08-12 14:42:27 -04:00
Aart Bik 8dd07e36ca [mlir][sparse] enable integral abs recognition
The end-to-end test for this new feature also exposed a bug
in LLVM IR lowering (since then, fixed), where we need to account
for the min-poison bit as extra argument.

    declare i32 @llvm.abs.i32(i32 <src>, i1 <is_int_min_poison>)

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D131712
2022-08-12 11:36:40 -07:00
Jacques Pienaar 2f025e0e78 [mlir][shape] Add dim op
Convenience op that allows for simple expression of common crossing of
value/shape divide.

Differential Revision: https://reviews.llvm.org/D131497
2022-08-12 11:02:08 -07:00
Jeff Niu bc8d966433 [mlir][math] Fix lowering of AbsIOp
The LLVM intrinsic has a bool flag `is_int_min_poison` that needs to be
set.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D131785
2022-08-12 12:10:15 -04:00
Alex Zinenko 4b45999bdd [mlir] fix crossed transform dialect patches
One patch added a use of the IR syntax that was changed by another.
2022-08-12 15:48:15 +00:00
Alex Zinenko a60ed95419 [mlir][transform] failure propagation mode in sequence
Introduce two different failure propagation mode in the Transform
dialect's Sequence operation. These modes specify whether silenceable
errors produced by nested ops are immediately propagated, thus stopping
the sequence, or suppressed. The latter is useful in end-to-end
transform application scenarios where the user cannot correct the
transformation, but it is robust enough to silenceable failures. It
can be combined with the "alternatives" operation. There is
intentionally no default value to avoid favoring one mode over the
other.

Downstreams can update their tests using:

  S='s/sequence \(%.*\) {/sequence \1 failures(propagate) {/'
  T='s/sequence {/sequence failures(propagate) {/'
  git grep -l transform.sequence | xargs sed -i -e "$S"
  git grep -l transform.sequence | xargs sed -i -e "$T"

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D131774
2022-08-12 15:31:22 +00:00
Matthias Springer 0581ab65ea [mlir][linalg][transform] Support matching of attributes (and their values)
Do not just check if an attribute exists on the payload op. Also check its value.

Differential Revision: https://reviews.llvm.org/D131760
2022-08-12 14:55:00 +02:00
Jinyun Joey Ye 921b13f263 Missing climits header file in MemRefUtils.h
MemRefUtils.h uses UINT_MAX, which is not included in current header files list. This patch include climits to avoid compilation error in this header file.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131529
2022-08-12 14:17:36 +02:00
Nicolas Vasilache a6bf6f25f0 [mlir][Linalg] Let FuseIntoContainingOp return success when nothing is fused.
This composes better when the op is applied in situations where it does not match.

Differential Revision: https://reviews.llvm.org/D131734
2022-08-12 02:18:31 -07:00
Matthias Springer bf1b9528ff [mlir][bufferize] Fix missing copy when bufferizing loops
Using a loop init_arg inside of the loop is not supported. This change adds a pre-processing pass that resolves such IR with copies.

Differential Revision: https://reviews.llvm.org/D131689
2022-08-12 10:44:55 +02:00
Marius Brehler f3547fd541 [mlir][emitc][nfc] Clean up tests
With https://reviews.llvm.org/D131666 the types were removed from the
EmitC opaque attributes. This cleans up the tests accordingly.
2022-08-12 08:25:31 +00:00
Alex Zinenko e8e718fa4b Revert "[mlir] Switch segment size attributes to DenseI32ArrayAttr"
This reverts commit 30171e76f0.

Breaks Python tests in MLIR, missing C API and Python changes.
2022-08-12 10:22:47 +02:00
Marius Brehler 90736babca [mlir][EmitC] Remove the type from the OpaqueAttr
This removes the type from EmitC's opaque attribute. The value provided
as a StringRefParameter can always be emitted as is. In consquence the
constant and variable ops explicitly need to opaque attributes which are
no longer typed attributes.

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

Reviewed By: Mogball, jpienaar

Differential Revision: https://reviews.llvm.org/D131666
2022-08-12 07:12:24 +00:00
Jeff Niu 30171e76f0 [mlir] Switch segment size attributes to DenseI32ArrayAttr
Switch variadic operand and result segment size attributes to use the
dense i32 array. Dense integer arrays were introduced primarily to
represent index lists. They are a better fit for segment sizes than
dense elements attrs.

Depends on D131738

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D131702
2022-08-11 20:56:45 -04:00
Jeff Niu 2092d1438c [mlir] Change the syntax of dense arrays
Follow-up to D123774, where the syntax of dense arrays was discussed. It
was included that the syntax should be changed to `array<i32: 1, 2>`.
This patch changes the syntax but importantly preserves the `[1, 2]`
syntax when embedding these attributes in assembly formats through ODS.

Reviewed By: mehdi_amini, jpienaar

Differential Revision: https://reviews.llvm.org/D131738
2022-08-11 20:56:42 -04:00
not-jenni 7ff0ca1a4d [mlir][tosa] Updates tosa.logical_not to use the SameOperandsAndResultType trait
Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D131496
2022-08-11 15:42:30 -07:00
Uday Bondhugula 0e54d9dfdc [MLIR] Fix hasNoInterveningEffect in the presence of ops from different affine scopes
Fix hasNoInterveningEffect in the presence of ops from different affine
scopes. Also, correctly check for dependence failures as well instead of
just for the existence of a dependence.

Differential Revision: https://reviews.llvm.org/D131641
2022-08-11 21:07:24 +05:30
Benjamin Kramer 726719e970 [mlir][sparse] Refine f695554a2a wording a bit and fix the double conversion I broke with aggressive copy&paste 2022-08-11 11:58:49 +02:00
Marius Brehler 91b6f76a58 [mlir] Fix calling the native mlir-pdll-tblgen
This sets the `MLIR_PDLL_TABLEGEN_EXE` and `MLIR_PDLL_TABLEGEN_TARGET`
as cache variables which is necessary for cross-compiling projects that
rely on MLIR and the mlir-pdll-tblgen tool.

The patch is similar to https://reviews.llvm.org/D130350.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D131596
2022-08-11 09:34:13 +00:00
Benjamin Kramer f695554a2a [mlir][sparse] Use the correct ABI on x86 and re-enable tests
c7ec6e19d5 made LLVM adhere to the x86
psABI and pass bf16 in SSE registers instead of GPRs. This breaks the
custom versions of runtime functions we have for bf16 conversion. A
great fix for this would be to use __bf16 types instead which carry the
right ABI, but that type isn't widely available.

Instead just pretend it's a 32 bit float on the ABI boundary and
carefully cast it to the right type.

Fixes #57042
2022-08-11 10:41:53 +02:00
Jeff Niu 5e0c3b4309 [mlir][LLVMIR] Clean up the definitions of ReturnOp/CallOp 2022-08-11 00:35:02 -04:00
Uday Bondhugula 3d93885f7c [MLIR][NFC] Refactor affine analysis helpers
Refactor affine analysis helpers: the existing ones were using
unnecessary or improperly named arguments. NFC.

Differential Revision: https://reviews.llvm.org/D131557
2022-08-11 06:28:59 +05:30
Uday Bondhugula b6164ec9c2 [MLIR] Add missing check for unsupported affine dependence analysis
Add missing check in affine dependence analysis when dependence analysis
isn't possible due to the ops being in different affine scopes.  The
lack of such a check could lead to a crash or incorrect behavior in
several dependent utilities.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131556
2022-08-11 06:02:39 +05:30
Uday Bondhugula 82973067ac [MLIR] Fix build breakage due to 5c5af910fe
Fix build breakage due to 5c5af910fe.

```commit 5c5af910fe
Author: Jeff Niu <jeff@modular.com>
Date:   Tue Aug 9 22:07:35 2022 -0400

    [mlir][LLVMIR] "Modernize" Insert/ExtractValueOp ```

results in

```lib/Conversion/LLVMCommon/MemRefBuilder.cpp:170:70: error: call of overloaded ‘makeArrayRef<int64_t>(<brace-enclosed initializer list>)’ is ambiguous
       llvm::makeArrayRef<int64_t>({kStridePosInMemRefDescriptor,
       pos}));

llvm/include/llvm/ADT/ArrayRef.h:505:15: note: candidate: ‘llvm::ArrayRef<T> llvm::makeArrayRef(const std::vector<T>&) [with T = long int]’
   ArrayRef<T> makeArrayRef(const std::vector<T> &Vec) {
               ^~~~~~~~~~~~
llvm/include/llvm/ADT/ArrayRef.h:516:37: note: candidate: ‘llvm::ArrayRef<T> llvm::makeArrayRef(const llvm::ArrayRef<T>&) [with T = long int]’
   template <typename T> ArrayRef<T> makeArrayRef(const ArrayRef<T> &Vec) {
                                                                      ^

Differential Revision: https://reviews.llvm.org/D131637
2022-08-11 05:58:38 +05:30
Aart Bik 6b7459115f [mlir][sparse][bf16] disable two bf16 tests
Supposedly our ABI issues were fixed, per issue:
https://github.com/llvm/llvm-project/issues/55992

However, with a recent changes to bf16, these tests
fail again; not sure why yet:
https://reviews.llvm.org/D130832
https://lab.llvm.org/buildbot/#/builders/61/builds/30600

So we disable the tests for now. Issue is tracked in:
https://github.com/llvm/llvm-project/issues/57042

Differential Revision: https://reviews.llvm.org/D131621
2022-08-10 15:50:27 -07:00
Jeff Niu aa543b8094 [mlir][ods] (NFC) split out erroring format tests 2022-08-10 15:36:12 -04:00
jackalcooper f230d91592 [mlir][spirv] Turn various passes to plain OperationPass
Made passes converting ops from other dialects to spirv OperationPass,
so that downstream compiler could put them in a proper nested pass
manager to lower device code only.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D131591
2022-08-10 13:50:07 -04:00
Slava Zakharin 08b4cf3620 [mlir][math] Added basic support for IPowI operation.
The operation computes pow(b, p), where 'b' and 'p' are signed integers
of the same width. The result's type matches the operands' type.

Differential Revision: https://reviews.llvm.org/D129809
2022-08-10 10:11:53 -07:00
Jeff Niu 5c5af910fe [mlir][LLVMIR] "Modernize" Insert/ExtractValueOp
This patch "modernizes" the LLVM `insertvalue` and `extractvalue`
operations to use DenseI64ArrayAttr, since they only require an array of
indices and previously there was confusion about whether to use i32 or
i64 arrays, and to use assembly format.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131537
2022-08-10 12:51:11 -04:00
Alexander Belyaev 47cf004076 [mlir] Fix win build by using has_value() instead of hasValue() for Optional. 2022-08-10 17:48:35 +02:00
Alexander Belyaev 42f32f69ad [mlir] Extract offsets-sizes-strides computation from `makeTiledShape(s)`.
This change separates computation of the actual parameters of the subset and
the materialization of subview/extract_slice. That way the users can still use
Linalg tiling logic even if they use different operations to materialize the
subsets.

Differential Revision: https://reviews.llvm.org/D131053
2022-08-10 15:37:38 +02:00
Alex Zinenko 2e2ad53979 [mlir] Generate C++ doc comments for interfaces
When emitting the declarations for interface methods defined in ODS,
also emit their descriptions as C++ comments. This makes the
documentation accessible to C++ tooling such as IDEs that offers better
usability than reading it form the .td or the website.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D130478
2022-08-10 15:12:29 +02:00
Jacques Pienaar 1f02ad7131 [mlir][shape] Update meet to handle all size & shape types
Also tighten up return type inference & compatibility functions.

Differential Revision: https://reviews.llvm.org/D130866
2022-08-10 05:08:24 -07:00
Dominik Adamski 98ed6e1069 [Flang][OpenMP] Fix conversion of nested loops for SIMD directive
Flang was not able to convert simd directive which contains nested
Fortran loops. The nested Fortran loops inside SIMD directive
are modelled as FIR loops and they need to be translated into LLVM
MLIR dialect.

Differential Revision: https://reviews.llvm.org/D131402

Reviewed by: peixin

Signed-off-by: Dominik Adamski <dominik.adamski@amd.com>
2022-08-10 03:54:30 -05:00
John Demme d44f8a50d5 [MLIR] [Python] Fix the Windows build broken by d747a17
Windows builds require all control paths return. Since we don't have
`llvm_unreachable` in the Python bindings, just return `None`.
2022-08-09 20:07:33 -07:00
John Demme d747a170a4 [MLIR] [Python] Fix `Value.owner` to handle BlockArgs
Previously, calling `Value.owner()` would C++ assert in debug builds if
`Value` was a block argument. Additionally, the behavior was just wrong
in release builds. This patch adds support for BlockArg Values.
2022-08-09 19:37:04 -07:00
Aart Bik 5110eb8b67 [mlir][sparse] fix doc
Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D131527
2022-08-09 17:19:39 -07:00
Jeff Niu 2f0e50c69b [mlir] Fix build of toyc-ch6 (NFC) 2022-08-09 15:58:49 -04:00
Jeff Niu f201476518 [mlir] Cleanup DenseArrayAttrBase definition and expose raw API
This patch cleans up the definition of `DenseArrayAttrBase` by relying
more on ODS-generated methods. It also exposes an API for using the raw
data of a dense array, similar to `DenseIntOrFPElementsAttr::getRaw`.

Reviewed By: lattner, mehdi_amini

Differential Revision: https://reviews.llvm.org/D131450
2022-08-09 15:43:45 -04:00
Jeff Niu 0af643f3ce [mlir][LLVMIR] (NFC) Add convenience builders for ConstantOp
And clean up some of the user code
2022-08-09 15:34:36 -04:00
Aart Bik 60076a9eaf [mlir][sparse] fix switch statement bug on two binary ops
They appeared at the wrong place in the switch, treating
them as unary op rather than binary op.

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D131509
2022-08-09 11:58:05 -07:00
Aart Bik 0cc6aac9fa [mlir][sparse] update bibliography of sparse tensor dialect
Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D131513
2022-08-09 11:57:01 -07:00
Lei Zhang 15135553c4 [mlir][spirv] Use functors for default memory space mappings
This makes it easier to use as a utility function to query the
mappings, including the reverse.

This commit also drops some storage classes that aren't needed
for now.

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D131411
2022-08-09 14:38:27 -04:00
Lei Zhang 89b595e141 [mlir][spirv] Detach memory space mapping from type conversion
This commit moves MemRef memory space to SPIR-V storage class
conversion out of the main SPIR-V type converter. Now the mapping
should happen as a prelimiary step before performing the final
conversion to SPIR-V. Flows are expect to write their own memory
space mappings like the `MapMemRefStorageClassPass` to handle
memory space mappings according to their needs.

This is needed because SPIR-V is serving multiple client APIs,
including Vulkan and OpenCL. Different client APIs might want
to use different storage classes for buffers in a particular
memory space, e.g., `StorageBuffer` for Vulkan vs. `CrossWorkgroup`
for OpenCL when converting the default 0 memory space.  Hardcoding
a specific mapping makes that hard. While it's possible to embed
selection logic further inside the main type converter, it will
make the main type converter even complicated. So it's better to
separate the concerns, as mapping the memory space is really
concretizing the meaning of those numeric memory spaces in the
particular context of SPIR-V lowering.

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D131410
2022-08-09 14:30:43 -04:00
Lei Zhang b83d0d46c0 [mlir][spirv] Make MemRef memory space mapping pass more flexible
* Avoid restricting the pass to to builtin module ops. The pass
  should be able to run on any region ops.
* Avoid hardcoding func FuncOp when handling functions. Instead,
  use the function op interface.
* Assigns the default mapping in the constructor. So for cases
  where we are using the pass in a pipeline, we still have a
  meaningful default.

Along the way, dropped uncessary unrealized conversion casts and
use full conversion. The pass should be able to convert all sorts
of ops; there is really no need to have such bridages.

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D131409
2022-08-09 14:21:50 -04:00
Jerry Wu 66c2b76846 [MLIR] Extend vector.gather to accept tensor as base
In addition to memref, accept ranked tensor as the base operand of vector.gather, similar to vector.trasnfer_read.

This will allow us to vectorize noncontiguous tensor.extract into vector.gather. Full discussion can be found here: https://github.com/iree-org/iree/issues/9198

Reviewed By: hanchung, dcaballe

Differential Revision: https://reviews.llvm.org/D130097
2022-08-09 11:19:16 -07:00
Jerry Wu 3597727fa7 [MLIR] Support lowering n-D arith.index_cast to LLVM
Previously we can only lower arith.index_cast with 1-D vectors to LLVM. This change added the support for n-D vectors.

Reviewed By: ftynse, hanchung

Differential Revision: https://reviews.llvm.org/D129907
2022-08-09 11:17:52 -07:00
Lei Zhang a29fffc475 [mlir][spirv] Migrate to use specalized enum attributes
Previously we are using IntegerAttr to back all SPIR-V enum
attributes. Therefore we all such attributes are showed like
IntegerAttr in IRs, which is barely readable and breaks
roundtripability of the IR. This commit changes to use
`EnumAttr` as the base directly so that we can have separate
attribute definitions and better IR printing.

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D131311
2022-08-09 14:14:54 -04:00
Aart Bik b09f6b471f [mlir][sparse] improve semi-ring doc
Spell out SparseVector instead of just using SparseVec

Reviewed By: jim22k, bixia

Differential Revision: https://reviews.llvm.org/D131511
2022-08-09 10:59:08 -07:00
Jakub Kuderski 08cc03befd [mlir][spirv] Clean up SPIRVOps.cpp. NFC.
Resolve almost all clang tidy warnings in this file:
1. Clean up string constants.
2. Use consistent argument names across function declarations and definitions. Rename `state` - > `result`, which is consistent with the other dialects.
3. Remove misleading function parameter name comments (`argTypes`). This did not match the actual function argument (`bool enableNameShadowing`).
4. Simplify calls to `is_splat`.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D131297
2022-08-09 10:40:43 -04:00
Benjamin Kramer 9fa59e7643 [mlir] Use C++17 structured bindings instead of std::tie where applicable. NFCI 2022-08-09 13:34:17 +02:00
Shraiysh Vaishay dd14d471a5 [mlir][OpenMP] omp.parallel side effects
Add `NoSideEffects` trait to omp.parallel operation.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D130657
2022-08-09 08:40:47 +00:00
Fangrui Song 5146f84fd6 LLVM_NODISCARD => [[nodiscard]]. NFC 2022-08-09 07:16:34 +00:00
Fangrui Song fc63c0542c [mlir] LLVM_FALLTHROUGH => [[fallthrough]]. NFC 2022-08-08 20:56:05 -07:00
Thomas Raoux 2eb50cee11 [mlir][tosa] Use arith::maxf/arith::minf in lowering from tosa
now that `arith` dialect has maxf/minf use it instead of cmp/select.
Also refactor clamp helpers to make them simlper.

Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D131426
2022-08-09 01:10:32 +00:00
not-jenni b73e8325fb [mlir][tosa] Updates tosa.equal to use the InferTensorType interface
Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D130373
2022-08-08 16:11:30 -07:00
Thomas Raoux 8d7c1c55a4 [mlir][vector] Fix warp distribution test
The test was using a missing prefix. Add the prefix and fix the naming.

Found by @csigg

Reviewed By: csigg

Differential Revision: https://reviews.llvm.org/D131428
2022-08-08 20:57:44 +00:00
Aart Bik 6b3bc7cd3c [mlir][sparse] improve sparse attribute documentation
Moved some parts from comments (not user facing) to the actual description
(user facing). Rephrased a bit as well.

Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D131418
2022-08-08 13:21:24 -07:00
Lei Zhang d9728a9baa [mlir][spirv] Unify mixed scalar/vector primitive type resources
This further relaxes the requirement to allow aliased resources
to have different primitive types and some are scalars while the
other are vectors.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D131207
2022-08-08 14:30:14 -04:00
Peiming Liu de907138ec [mlir][sparse] Add new concatente operator to sparse tensor
See https://www.tensorflow.org/xla/operation_semantics#concatenate for the operator semantics

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D131111
2022-08-08 17:23:43 +00:00
Benjamin Kramer 2cbfa93f42 [mlir][math] Fix pythong bindings after 00f7096d31 2022-08-08 19:14:44 +02:00
Mehdi Amini 95b3ff08f5 [mlir][doc] Cross link the dependent dialect section to the tablegen field definition 2022-08-08 16:57:33 +00:00
Rajas Vanjape 333f98b4b6 [mlir][sparse][nfc] Use tensor.generate in sparse integration tests
Currently, dense tensors are initialized in Sparse Integration tests using
"buffer.tensor_alloc and scf.for" . This makes code harder to read and maintain.
This diff uses tensor.generate instead to initialize dense tensors.

Testing: Ran integration tests after building with -DLLVM_USE_SANITIZER=Address flag.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D131404
2022-08-08 16:44:45 +00:00
lorenzo chelini fb33b406df [MLIR][Linalg] Remove `TiledLoops` from tiling options
TiledLoopOp has been removed in: 1a829d2d06

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131383
2022-08-08 18:24:58 +02:00
Benjamin Kramer 2960299986 [ADT] Retire llvm::apply_tuple in favor of C++17 std::apply 2022-08-08 18:23:38 +02:00
Lei Zhang 4bd25d0b81 [mlir][spirv] Refresh base definitions to latest spec (v1.6)
This commit updates all SPIR-V enum definitions to match the latest
specification (v1.6 revision 2). Along the way, fixed some issues
in `gen_spirv_dialect.py` and added a new script for refreshing
all op definitions for such cases.

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D131293
2022-08-08 12:22:32 -04:00
Jeff Niu 7d9fc95b85 [mlir][math] Add `math.absi` op
Adds an integer absolute value op to the math dialect.

When converting to LLVM, this op is lowered to the LLVM `abs` intrinsic.
When converting to SPIRV, this op is lowered to `spv.GL.SAbs`.

Depends on D131325

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131327
2022-08-08 11:05:01 -04:00
Jeff Niu 00f7096d31 [mlir][math] Rename math.abs -> math.absf
To make room for introducing `math.absi`.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D131325
2022-08-08 11:04:58 -04:00
Arjun P dc07d2c91d [MLIR][Presburger] make sample test with integer lexmin use containsPointNoLocal
IntegerPolyhedron::findIntegerLexmin currently does not return values of
the local ids, so when a test for sampling includes a set with locals, the
result of findIntegerLexmin should be checked using containsPointNoLocal,
not containsPoint.
2022-08-08 14:46:02 +01:00
Markus Böck 8805cf2660 [mlir] Remove redundant `inline` from D131323 2022-08-08 13:18:09 +02:00
Ashay Rane d1bb3016dd
[mlir] fix `add_tablegen()` macro to allow installing mlir-pdll
Prior to this patch, the `add_tablegen()` macro in
llvm/cmake/modules/TableGen.cmake added the install rule only if
`project` matched `LLVM` or `MLIR`.  This patch adds an optional
`DESTINATION` argument, which, if non-empty, decides whether (and where)
to install the tablegen tool, thus eliminating the need for
project-specific overrides.  This patch also updates all other
invocations of the `add_tablegen()` macro.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D131282
2022-08-07 15:48:38 -07:00
Jacques Pienaar 10de551297 [mlir][python] Address deprecation warning for hasValue 2022-08-07 15:28:18 -07:00
Kazu Hirata f616a63db2 [mlir] Use value instead of getValue 2022-08-07 11:59:37 -07:00
Kazu Hirata 5b14c7aee8 [mlir] Fix a warning
This patch fixes:

  llvm-project/mlir/include/mlir/IR/OpDefinition.h:1544:19: error: use
  of bitwise '|' with boolean operands
  [-Werror,-Wbitwise-instead-of-logical]
2022-08-07 11:13:19 -07:00
Jacques Pienaar 7602e285f6 [mlir] Flip to prefixed accessors (NFC)
Missed these in td files.
2022-08-07 08:46:15 -07:00
Jacques Pienaar d3b3f7653d [mlir] Flip to prefixed accessors (NFC) 2022-08-07 04:55:58 -07:00
Markus Böck 26d811b3ec [mlir] Make use of C++17 language features
Now that C++17 is enabled in LLVM, a lot of the TODOs and patterns to emulate C++17 features can be eliminated.
The steps I have taken were essentially:
```
git grep C++17
git grep c++17
git grep "initializer_list<int>"
```
and address given comments and patterns.
Most of the changes boiled down to just using fold expressions rather than initializer_list.

While doing this I also discovered that Clang by default restricts the depth of fold expressions to 256 elements. I specifically hit this with `TestDialect` in `addOperations`. I opted to not replace it with fold expressions because of that but instead adding a comment documenting the issue.
If any other functions may be called with more than 256 elements in the future we might have to revert other parts as well.
I don't think this is a common occurence besides the `TestDialect` however. If need be, this could potentially be fixed via `mlir-tblgen` in the future.

Differential Revision: https://reviews.llvm.org/D131323
2022-08-07 11:16:49 +02:00
Kazu Hirata af2d2d7759 [mlir] Remove redundaunt return statements (NFC)
Identified with readability-redundant-control-flow.
2022-08-07 00:16:13 -07:00
John Demme 5e9b6a2243 [MLIR] Add MlirValue to PybindAdapters
Allows out-of-tree users to automatically cast to/from MlirValue.
2022-08-06 21:58:46 -07:00
Jacques Pienaar 4401bde317 [mlir][tosa] Flip to prefixed form.
Flipped to _Both 2 weeks ago, flipping to _Prefixed now.
2022-08-06 19:24:40 -07:00
Kazu Hirata c8e6ebd74e Use value instead of getValue (NFC) 2022-08-06 11:21:39 -07:00
Kazu Hirata 9750648cb4 [mlir, flang] Use has_value instead of hasValue (NFC) 2022-08-06 11:12:47 -07:00
Markus Böck 1c5a50e328 [mlir][tblgen] Refact mlir-tblgen main into its own library
This has previously been done for `mlir-opt` and `mlir-reduce` and roughly the same approach has been done here.

The use case for having a separate library is that it is easier for downstream to make custom TableGen backends/executable that work on top of the utilities that are defined in `mlir/TableGen`.
The customization point here is the same one as for any upstream TableGen backends: One can add a new generator by simply creating a global instance of `mlir::GenRegistration`.

Differential Revision: https://reviews.llvm.org/D131112
2022-08-06 14:07:37 +02:00
Eugene Zhulenev 5f1c7e2cc5 [mlir] Use SymbolTableCollection to lookup referenced symbol in AddressOfOp
Depends On D131285

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D131291
2022-08-05 14:05:03 -07:00
Eugene Zhulenev 51bc82d147 [mlir] Implement SymbolUserOpInterface in LLVM::CallOp
Avoid expensive calls to `SymbolTable::lookupNearestSymbolFrom` in verifier

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D131285
2022-08-05 13:50:31 -07:00
Jakub Kuderski 5c16eeb7ee [mlir][spirv] Define spv.IAddCarry
Based on `spv.ISubBorrow` from D127909.
Also resolved some clang-tidy warnings.

Reviewed By: antiagainst, ThomasRaoux

Differential Revision: https://reviews.llvm.org/D131281
2022-08-05 16:45:51 -04:00
Eugene Zhulenev 292e8ed49a [mlir] Use SymbolUserOpInterface in LLVM::AddressOfOp verifier
Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D131271
2022-08-05 10:51:30 -07:00
Lei Zhang 1f7544a679 [mlir][spirv] Add default Vulkan memory space to storage class mapping
Reviewed By: ThomasRaoux, kuhar

Differential Revision: https://reviews.llvm.org/D131128
2022-08-05 12:30:14 -04:00