Commit Graph

12541 Commits

Author SHA1 Message Date
Oleg Shyshkov fcab0a04c5 [mlir] Change CombiningKind in Vector dialect to EnumAttr.
CombiningKind was implemented before EnumAttr, so it reimplements the same behaviour with the custom code. Except for a few places, EnumAttr is a drop-in replacement.

Reviewed By: nicolasvasilache, pifon2a

Differential Revision: https://reviews.llvm.org/D133343
2022-09-07 13:40:45 +02:00
Mehdi Amini b285d708a7 Apply clang-tidy fixes for performance-for-range-copy in TileUsingInterface.cpp (NFC) 2022-09-07 09:40:59 +00:00
Mehdi Amini 8eab900170 Apply clang-tidy fixes for llvm-qualified-auto in Bufferize.cpp (NFC) 2022-09-07 09:40:59 +00:00
Alexander Belyaev 4bf84e433d [mlir] Remove `materializeOpFoldResult` functions.
We can use `getValueOrCreateConstantIndexOp` instead.

Differential Revision: https://reviews.llvm.org/D133403
2022-09-07 10:22:42 +02:00
Uday Bondhugula 8d7f270186 [MLIR] NFC. Introduce mlir::hasEffect and refactor usages dialect util
Introduce mlir::hasEffect and refactor existing usage to use utility.
NFC.

Reviewed By: rriddle, mehdi_amini

Differential Revision: https://reviews.llvm.org/D132117
2022-09-07 12:21:57 +05:30
jacquesguan ac66d87c4b [mlir][Math] Add constant folder for RoundEvenOp.
This patch uses roundeven/roundevenf of libm to fold RoundEvenOp of constant.

Differential Revision: https://reviews.llvm.org/D133344
2022-09-07 11:13:00 +08:00
jacquesguan e3434a8627 [mlir][Math] Add constant folder for CosOp.
This patch adds constant folder for CosOp which only supports single and double precision floating-point.

Differential Revision: https://reviews.llvm.org/D131233
2022-09-07 10:54:08 +08:00
natashaknk e47ca72e30 [mlir][tosa] Support non-batch dynamic dims for tosa.rescale to linalg
Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D133383
2022-09-06 17:30:02 -07:00
River Riddle bb6d12b5ce [mlir] Flip default value of emitAccessorPrefix to kEmitAccessorPrefix_Prefixed
Most dialects have already flipped to prefixed, and the intention to switch
has been telegraphed for a while.

Differential Revision: https://reviews.llvm.org/D133179
2022-09-06 15:56:57 -07:00
Anastasia Stulova e28a5ceca9 [mlir][tosa] Fix dynamic shape inference in conv2d
The comment in the code correctly states the equation for the shape inference as follows:

```
H = ((IH+pad_top+pad_bottom-(dilation_y*(KH-1)+1))/stride_y)+1
```

However the final operation is generated as `-` instead of `+`. I believe `+`
is indeed correct. For example if we have an image with dimension 6 and kernel
of dimension 3 (assuming padding is 0 and stride and dilation are both 1) we
are expecting 4 elements in the output (computed for image elements `(0, 1, 2)
x kernel`, `(1, 2, 3) x kernel`, `(2, 3, 4) x kernel` and `(3, 4, 5) x kernel`.
However currently only 2 elements are produced in the output.

Reviewed By: NatashaKnk

Differential Revision: https://reviews.llvm.org/D133208
2022-09-06 15:42:04 -07:00
Peiming Liu 67dc6674c1 [mlir][tensor] Fix a typo in the example code for UnrankedTensorType
The syntax for unrank tensor type is defined as  tensor-type ::= `tensor` `<` `*` `x` type `>`, the example code missed the `x` in between.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133381
2022-09-06 22:31:47 +00:00
River Riddle 82b6549654 [mlir:vscode] Add support for loading big bytecode files
VSCode doesn't let our extension manage files >50mb. This commit
adds a proper diagnostic in this case, and also gives the user an option
to open as a temporary .mlir file instead.

Differential Revision: https://reviews.llvm.org/D133242
2022-09-06 14:49:16 -07:00
River Riddle f3502afe85 [mlir] Allow passing AsmState when printing Attributes and Types
This allows for extracting assembly information when printing an attribute
or type, such as the dialect resources referenced. This functionality is used in
a followup that adds resource support to the bytecode. This change also results
in a nice cleanup of AsmPrinter now that we don't need to awkwardly workaround
optional AsmStates.

Differential Revision: https://reviews.llvm.org/D132728
2022-09-06 14:45:12 -07:00
Krzysztof Drewniak 839b436c93 [mlir] Improve BitEnumAttr, update documentation
- Add new operators to BitEnumAttr, mainly not (which only inverts
bits that can be valid bits for the attribute) and xor
- Add new bit enum utility functions: bitEnumClear(bits, bit) and
bitEnumSet(bits, bit, value=true) as they've come up in code I've been
writing that makes use of such enums
- Add rudimentary tests for the enum generator
- Update the OpDefinition documentation to make it contain a correct
example and to have it account for the changes mentioned above.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D133374
2022-09-06 21:36:34 +00:00
Peiming Liu d50d678854 [mlir][sparse] Add lowering rules for sparse_tensor.storage Op
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133368
2022-09-06 21:04:16 +00:00
Chenguang Wang ae60a4a0ef [mlir] Fix DenseElementsAttr::mapValues(i1, splat).
Splat of bool is encoded as a byte with all-ones in it [1]. Without this
change, this piece of code:

    auto xs = builder.getI32TensorAttr({42, 42, 42, 42});
    auto xs2 = xs.mapValues(builder.getI1Type(), [](const llvm::APInt &x) {
      return x.isZero() ? llvm::APInt::getZero(1) : llvm::APInt::getAllOnes(1);
    });
    xs2.dump();

Prints:

    dense<[true, false, false, false]> : tensor<4xi1>

Because only the first bit is set. This applies to both
DenseIntElementsAttr::mapValues() and DenseFPElementsAttr::mapValues().

[1]: e877b42e2c/mlir/lib/IR/BuiltinAttributes.cpp (L984)

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D132767
2022-09-06 21:28:25 +02:00
Krzysztof Drewniak 405af8e520 [mlir] Make bit enum operators constexpr
This allows using the | operator on the values of enum attributes
in complie-time constants.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D133159
2022-09-06 17:39:44 +00:00
Jakub Kuderski 817de304d5 [mlir][spirv] Change vendor op mnemonics to `spv.VENDOR.name`
Make vendor ops more consistent with the naming scheme within the SPIR-V
dialect.

Issue: https://github.com/llvm/llvm-project/issues/56863

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D133247
2022-09-06 13:35:08 -04:00
Jakub Kuderski b8bea837f3 [mlir][spirv] Refactor vendor op definitions
Use dedicated vendor op classes/categories. This is so that we can later
change the mnemonics of all vendor ops by changing the base class: `SPV_VendorOp`.

Issue: https://github.com/llvm/llvm-project/issues/56863
2022-09-06 13:35:08 -04:00
Jakub Kuderski 6a378b38ff [mlir][spirv] Add base classes for vendor ops
This is the first patch in the series to rename vendor ops from
`spv.NameVENDOR` to `spv.VENDOR.Name`. The goal is to make the SPIR-V
dialect more internally consistent.

Issue: https://github.com/llvm/llvm-project/issues/56863
2022-09-06 13:35:08 -04:00
Peiming Liu 4c46a5d54d [mlir][sparse] Refactoring: renaming StorageNewOp to StorageOp
To address comment in https://reviews.llvm.org/D133241

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133363
2022-09-06 17:02:25 +00:00
Aart Bik 0c7abd3924 [mlir][sparse] codegen for sparse alloc
Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D133241
2022-09-06 09:37:54 -07:00
Alexander Belyaev c141c03fd8 [mlir] Add materializeOpFoldResults to turn OpFoldResult array into values.
Differential Revision: https://reviews.llvm.org/D133346
2022-09-06 13:38:05 +02:00
Christian Sigg 3a90af15cf [MLIR] Fix for commit 0f2ec35
Fix incorrectly formatted python file.
2022-09-06 12:53:58 +02:00
Christian Sigg 0f2ec35691 [MLIR] Switch lit tests to %mlir_lib_dir and %mlir_src_dir replacements.
The old replacements will be removed soon:
- `%linalg_test_lib_dir`
- `%cuda_wrapper_library_dir`
- `%spirv_wrapper_library_dir`
- `%vulkan_wrapper_library_dir`
- `%mlir_runner_utils_dir`
- `%mlir_integration_test_dir`

Reviewed By: herhut

Differential Revision: https://reviews.llvm.org/D133270
2022-09-06 12:34:14 +02:00
Mehdi Amini af72641d29 Apply clang-tidy fixes for readability-identifier-naming in OpenMPDialect.cpp (NFC) 2022-09-06 09:59:30 +00:00
Mehdi Amini 1e7b48a6c3 Apply clang-tidy fixes for readability-identifier-naming in OptimizeSharedMemory.cpp (NFC) 2022-09-06 09:59:30 +00:00
Matthias Springer f7dd9a3206 [mlir][bufferize] Add new debug flag: copy-before-write
If this flag is set, the analysis is skipped and buffers are copied before every write.

Differential Revision: https://reviews.llvm.org/D133288
2022-09-05 14:41:19 +02:00
Mehdi Amini d2c7c725c1 Apply clang-tidy fixes for readability-simplify-boolean-expr in NVGPUDialect.cpp (NFC) 2022-09-05 12:34:47 +00:00
Mehdi Amini 2fe37d1c7e Apply clang-tidy fixes for performance-unnecessary-value-param in FoldMemRefAliasOps.cpp (NFC) 2022-09-05 12:34:46 +00:00
Mehdi Amini 89418ddcb5 Plumb write_bytecode to the Python API
This adds a `write_bytecode` method to the Operation class.
The method takes a file handle and writes the binary blob to it.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D133210
2022-09-05 12:02:06 +00:00
Markus Böck f570cc173d [mlir][NFC] Move CodeGenHelpers.cpp from mlir-tblgen to TableGen library
Its header was already part of the TableGen library, but unusable as uses of its functions or classes would lead to undefined references when linking. This fixes that.
2022-09-05 13:05:57 +02:00
Johannes Reifferscheid 34f4a9ef2a Add ArithBuilder::sub, make add, mul work with IndexTypes.
sgt and slt already worked with IndexTypes, the others did not.

Reviewed By: pifon2a

Differential Revision: https://reviews.llvm.org/D133285
2022-09-05 12:44:19 +02:00
Nicolas Vasilache d2613d5bb5 [mlir][tensor] Add gather/scatter op definitions to the tensor dialect.
Gather/Scatter are examined from first principles in light of our recent progress on tensor-based codegen
and in-place bufferization.

In the future, lowering of these abstractions to operate **inplace** on buffers
will likely require a more powerful buffer representation than strided memref.

General context: https://discourse.llvm.org/t/rfc-structured-codegen-beyond-rectangular-arrays/64707
Relevant TL;DR parts of the proposal:
- gather: https://discourse.llvm.org/t/rfc-structured-codegen-beyond-rectangular-arrays/64707#proposal-gatherop-and-friends-10
- need for more expressive types: https://discourse.llvm.org/t/rfc-structured-codegen-beyond-rectangular-arrays/64707#proposal-bufferization-copy-view-and-the-need-for-more-expressive-types-12
- jagged buffer discussion: https://discourse.llvm.org/t/rfc-structured-codegen-beyond-rectangular-arrays/64707#proposal-first-class-jagged-buffer-13

Differential Revision: https://reviews.llvm.org/D130348
2022-09-05 02:02:22 -07:00
Mehdi Amini 28e5e3d634 Apply clang-tidy fixes for performance-for-range-copy in TilingInterfaceImpl.cpp (NFC) 2022-09-04 10:41:30 +00:00
Mehdi Amini a7a892ae95 Apply clang-tidy fixes for readability-identifier-naming in Tiling.cpp (NFC) 2022-09-04 10:41:30 +00:00
Kazu Hirata f11925e0f0 [mlir] Use std::enable_if_t (NFC) 2022-09-03 23:27:20 -07:00
Nick Kreeger 30ceb783e2 [mlir][sparse] Expose SparseTensor passes as enums instead of opaque numbers for vectorization and parallelization options.
The SparseTensor passes currently use opaque numbers for the CLI, despite using an enum internally. This patch exposes the enums instead of numbered items that are matched back to the enum.

Fixes https://github.com/llvm/llvm-project/issues/53389

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

Please also see:
https://reviews.llvm.org/D118379
https://reviews.llvm.org/D117919
2022-09-04 01:39:35 +00:00
Vitaly Buka 4ff5bf28f0 [test][mlir] Restore used attributes deleted by D132726 2022-09-03 14:14:36 -07:00
Nick Kreeger 91470d6352 Revert "[mlir][sparse] Expose SparseTensor passes as enums instead of opaque"
This reverts commit ef25b5d93d.
2022-09-03 15:47:40 -05:00
Nick Kreeger ef25b5d93d [mlir][sparse] Expose SparseTensor passes as enums instead of opaque
numbers for vectorization and parallelization options.

The SparseTensor passes currently use opaque numbers for the CLI,
despite using an enum internally. This patch exposes the enums instead
of numbered items that are matched back to the enum.

Fixes https://github.com/llvm/llvm-project/issues/53389

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

Please also see:
https://reviews.llvm.org/D118379
https://reviews.llvm.org/D117919
2022-09-03 15:45:49 -05:00
Christian Sigg f43c81470b [MLIR] Single lit config attribute for CMAKE_LIBRARY_OUTPUT_DIRECTORY
Replace the following config attributes with `mlir_lib_dir`:
- `mlir_runner_utils_dir`
- `linalg_test_lib_dir`
- `spirv_wrapper_library_dir`
- `vulkan_wrapper_library_dir`
- `mlir_integration_test_dir`

I'm going to clean up substitutions in separate changes.

Reviewed By: aartbik, mehdi_amini

Differential Revision: https://reviews.llvm.org/D133217
2022-09-03 16:04:07 +02:00
Christian Sigg 9f358c8ef7 Resubmit "[MLIR] Remove unused config attributes from lit.site.cfg.py"
This resubmits commit 0816b62, reverted in commit 328bbab, but without removing the config.target_triple.

Lit checks UNSUPPORTED tags in the input against the config.target_triple (https://llvm.org/docs/TestingGuide.html#constraining-test-execution).

The original commit made the following bots start failing, because unsupported tests were no longer skipped:
- s390x: https://lab.llvm.org/buildbot/#/builders/199/builds/9247
- Windows: https://lab.llvm.org/buildbot/#/builders/13/builds/25321
- Sanitizer: https://lab.llvm.org/buildbot/#/builders/5/builds/27187
2022-09-03 09:02:37 +02:00
Mehdi Amini 95201fcca0 Revert "[mlir][cmake] Don't add dependencies on mlir-(generic-)headers"
This reverts commit 7691b69d5b.

Bots are broken because we're missing CMake dependencies all around now.
2022-09-03 01:45:18 +00:00
River Riddle f7b8a70e7a [mlir:vscode] Add support for viewing and editing a bytecode file as .mlir
This commit adds support for interacting with a (valid) bytecode file in the same
way as .mlir. This allows editing, using all of the traditional LSP features, etc. but
still using bytecode as the on-disk serialization format. Loading a bytecode file this
way will fail if the bytecode is invalid, and saving will fail if the edited .mlir is invalid.

Differential Revision: https://reviews.llvm.org/D132970
2022-09-02 18:16:05 -07:00
Peiming Liu c3aeb3e644 [mlir][sparse] Introduce sparse_tensor.storage operator to create a sparse tensor storage tuple
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D133231
2022-09-03 00:08:29 +00:00
Mehdi Amini 0b1aee38bd Revert "[mlir][Tensor] Add rewrites to extract slices through `tensor.collape_shape`"
This reverts commit 5711957875.

A circular dependency is introduced here from Dialect/Utils/ to the
ViewLikeInterface, but it already depends on Dialect/Utils.

Also this introduces a dependency from lib/Dialect/Tensor to Linalg,
which isn't obviously correct from a layering point of view.
2022-09-02 23:34:52 +00:00
Lei Zhang 53dac0980d [mlir][spirv] Convert some 0-D vector extract/insertelement ops
Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D133183
2022-09-02 17:47:49 -04:00
Mitch Phillips 328bbab542 Revert "[MLIR] Remove unused config attributes from lit.site.cfg.py"
This reverts commit 0816b629c9.

Reason: Broke the sanitizer buildbots. More information available in the
original phabricator review: https://reviews.llvm.org/D132726
2022-09-02 14:40:28 -07:00
Manish Gupta fbf69f95b6 [mlir][NVGPU] Adding Support for cp_async_zfill via Inline Asm
`cp_async_zfill` is currently not present in the nvvm backend, this patch adds `cp_async_zfill` support by adding inline asm when lowering from `nvgpu` to `nvvm`.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D132269
2022-09-02 21:29:26 +00:00