Commit Graph

19689 Commits

Author SHA1 Message Date
Oleksandr "Alex" Zinenko
105c992c83 [mlir] use irdl as matcher description in transform (#89779)
Introduce a new Transform dialect extension that uses IRDL op
definitions as matcher descriptors. IRDL allows one to essentially
define additional op constraits to be verified and, unlike PDL, does not
assume rewriting will happen. Leverage IRDL verification capability to
filter out ops that match an IRDL definition without actually
registering the corresponding operation with the system.
2024-05-02 15:03:30 +02:00
Brian Gesiak
11bda17254 [mlir-lsp] Parse outgoing request callback JSON (#90693)
Rather than force callbacks for outgoing requests to parse the result
JSON themselves (of type `llvm::Expected<llvm::json::Value>`), allow
users to specify the result type, which
`MessageHandler::outgoingRequest` will parse for them. This eliminates
boilerplate for users sending outgoing requests.
2024-05-02 09:02:13 -04:00
Oleksandr "Alex" Zinenko
a2e1f54bb7 [mlir] remove test-tranfsorm-dialect-interpreter (#89931)
This pass has been deprecated for more than two months, alternative is
available via `-transform-interpreter` and `-transform-preload-library`.


https://discourse.llvm.org/t/psa-deprecating-test-transform-dialect-interpreter/76904
2024-05-02 14:52:17 +02:00
Peiming Liu
78885395c8 [mlir][sparse] support tensor.pad on CSR tensors (#90687) 2024-05-01 15:37:38 -07:00
Tai Ly
82383d5f3f [mlir][tosa] Rename Tosa Div op to IntDiv Op (#80047)
This patch renames Tosa Div Op to IntDiv Op to align with the TOSA Spec.

<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/llvm/llvm-project/80047)
<!-- Reviewable:end -->

Signed-off-by: Tai Ly <tai.ly@arm.com>
2024-05-01 13:26:42 -07:00
Kojo Acquah
6dfaecf077 [mlir][Vector] Add patterns for efficient unsigned i4 -> i8 conversion emulation (#89131)
This PR builds on https://github.com/llvm/llvm-project/pull/79494 with an additional path for efficient unsigned `i4 ->i8` type extension for 1D/2D operations. This will impact any i4 -> i8/i16/i32/i64 unsigned extensions as well as sitofp i4 -> f8/f16/f32/f64.
2024-05-01 12:32:20 -04:00
Benjamin Maxwell
9226688596 [mlir][ArmSME] Add a tests showing liveness issues in the tile allocator (#90447)
This test shows a few cases (not at all complete) where the current
ArmSME tile allocator produces incorrect results. The plan is to resolve
these issues with a future tile allocator that uses liveness
information.
2024-05-01 16:09:26 +01:00
Quinn Dawkins
75f7295419 [mlir][Tensor] Fix unpack -> transpose folding pattern for padded unpacks (#90678)
Previously if the producer tensor.unpack op had "unpadding" semantics,
the folding pattern would construct a destination that does not match
with the result type of the transpose. Because both ops are DPS we can
just reuse the destination of the transpose.

Additionally cleans up a bunch of trailing whitespace in the test file.
2024-04-30 20:17:35 -04:00
Han-Chung Wang
a1423ba427 [mlir][tensor] Fix integration tests that uses reshape ops. (#90649)
Due to generalization introduced in
https://github.com/llvm/llvm-project/pull/90040
2024-04-30 12:34:03 -07:00
Peiming Liu
7cbaaed636 [mlir][sparse] fix sparse tests that uses reshape operations. (#90637)
Due to generalization introduced in
https://github.com/llvm/llvm-project/pull/90040
2024-04-30 11:57:16 -07:00
Peiming Liu
d2353695f8 [mlir][NFC] update code to use mlir::dyn_cast/cast/isa (#90633)
Fix compiler warning caused by using deprecated interface
(https://github.com/llvm/llvm-project/pull/90413)
2024-04-30 11:14:11 -07:00
Matthias Gehre
30badf96bb [MLIR][Arith] expand-ops: Support mini/maxi (#90575)
Expand `arith.minsi`, `arith.minui`, `arith.maxsi`, `arith.maxui` into
`arith.cmpi` and `arith.select`.

---------

Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
2024-04-30 19:02:32 +02:00
Peiming Liu
dbe376651a [mlir][sparse] handle padding on sparse levels. (#90527) 2024-04-30 09:53:44 -07:00
Gaurav Shukla
97069a8619 [MLIR] Generalize expand_shape to take shape as explicit input (#90040)
This patch generalizes tensor.expand_shape and memref.expand_shape to
consume the output shape as a list of SSA values. This enables us to
implement generic reshape operations with dynamic shapes using
collapse_shape/expand_shape pairs.

The output_shape input to expand_shape follows the static/dynamic
representation that's also used in `tensor.extract_slice`.

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

---------

Signed-off-by: Gaurav Shukla<gaurav.shukla@amd.com>
Signed-off-by: Gaurav Shukla <gaurav.shukla@amd.com>
Co-authored-by: Ramiro Leal-Cavazos <ramiroleal050@gmail.com>
2024-04-30 09:28:35 -07:00
Alexandre Eichenberger
a7b968a578 Adding memref normalization of affine.prefetch (#89675)
Added support for memref-normalization for prefetch.

Signed-off-by: Alexandre Eichenberger <alexe@us.ibm.com>
2024-04-30 10:54:15 -04:00
Maya Amrami
5cd074fa57 [mlir] Add ReifyRankedShapedTypeOpInterface to tosa::TransposeOp (#88890) 2024-04-30 14:48:58 +03:00
Christian Sigg
7ac1fb01e9 [mlir] Mark isa/dyn_cast/cast/... member functions deprecated. (#90413)
This also removes the member overload in TypeSwitch.

All other users have been removed in
fac349a169 and
bd9fdce69b.
2024-04-30 10:33:05 +02:00
Andrzej Warzyński
c9d92d215e [mlir][test] Add TD example for peel+vectorize (depthwise conv) (#90200)
Adds an example that combines loop peeling and scalable vectorisation of
`linalg.depthwise_conv_2d_nhwc_hwc`. This is similar to
transform-op-peel-and-vectorize.mlir and is meant to demonstrate how to
avoid masking when vectorising using scalable vectors.
2024-04-30 09:02:16 +01:00
Johannes de Fine Licht
92ca6fcb87 [MLIR][LLVM] Have LLVM::AddressOfOp implement ConstantLike (#90481)
For all means and purposes llvm.mlir.addressof acts like a constant, and
should be treated as such by passes. In particular, the operation should
be propagated rather than passed whenever possible.
2024-04-30 10:00:28 +02:00
Johannes de Fine Licht
2464c1c153 [MLIR] Sprinkle extra asserts in OperationSupport.h (#90465)
Should hopefully help shave some minutes off developer debugging time in
the future.
2024-04-30 10:00:04 +02:00
Kareem Ergawy
ce12b12d0d [mlir][OpenMP] Extend omp.private with a dealloc region (#90456)
Extends `omp.private` with a new region: `dealloc` where deallocation
logic for Fortran deallocatables will be outlined (this will happen in
later PRs).
2024-04-30 08:49:51 +02:00
Aart Bik
65ee8f10b2 [mlir][sparse] fold explicit value during sparsification (#90530)
This ensures the explicit value is generated (and not a load into the
values array). Note that actually not storing values array at all is
still TBD, this is just the very first step.
2024-04-29 18:06:07 -07:00
Brian Gesiak
e24a7bbf45 [mlir-lsp] Support outgoing requests (#90078)
Add support for outgoing requests to `lsp::MessageHandler`. Much like
`MessageHandler::outgoingNotification`, this allows for the message
handler to send outgoing messages via its JSON transport, but in this
case, those messages are requests, not notifications.

Requests receive responses (also referred to as "replies" in
`MLIRLspServerSupportLib`). These were previously unsupported, and
`lsp::MessageHandler` would log an error each time it processed a JSON
message that appeared to be a response (something with an "id" field,
but no "method" field). However, the `outgoingRequest` method now
handles response callbacks: an outgoing request with a given ID is set
up such that a callback function is invoked when a response with that ID
is received.
2024-04-29 18:43:08 -04:00
Peiming Liu
7e2eeb5753 [mlir][sparse] use ValueRange instead of std::pair for iterator position. (#90243)
`ValueRange` is more easy to be extended (e.g., for padded iterator).
2024-04-29 10:47:07 -07:00
Mehdi Amini
d566a5cd22 [MLIR] Improve KernelOutlining to avoid introducing an extra block (#90359)
This fixes a TODO in the code.
2024-04-29 19:30:38 +02:00
Brian Gesiak
b811ad6f34 [mlir-lsp] Un-revert unit test additions (#90232)
This reverts the revert commit 6844c2feae, which was comprised
of the following commits:

1. f3f6f22dfc - [mlir-lsp] Initialize `Reply::method` member (#89857)
2. 37e13d4924 - [mlir-lsp] Log invalid notification params (#89856)
3. ba1b52e6e7 - [mlir-lsp] Add `outgoingNotification` unit test
4. 84bc21f910 - [mlir-lsp] Add transport unit tests (#89855)

Of these, (4) specifically caused issues in Windows pre-merge buildbots,
in the `TransportTest.MethodNotFound` unit test that it added. The
failure was caused by a statement that asserted that opening a file
stream on a newly created temporary file did not result in an error, but
this assert failed on Windows.

This patch adds additional error logging for failures, to make it
clearer what went wrong when failures occur. This patch also addresses
the Windows failure by ensuring temporary files are created in the
system temporary directory.
2024-04-29 10:54:31 -04:00
Renato Golin
5e3032638e [MLIR][Linalg] Left over Linalg named ops from previous PR (#90405)
Adding `erf` as unary and `powf` as binary.

Same as `max(arg, 0.0)` for `ReLU`, `powf(arg, const)` can be either a
generic (with broadcast) or a pair (`linalg.broadcast + linalg.powf`)
and then lowered "correctly". Either way, the lower dialects need to
know what kind of broadcast anyway, so no materialization of the
constant tensors should remain.

I want to flush the easy ones before we start working on type cast &
softmax.
2024-04-29 15:42:35 +01:00
Matthias Springer
179e174945 [mlir][bufferization][NFC] More documentation for runOneShotBufferize (#90445) 2024-04-29 13:23:37 +02:00
Maciej Gabka
bfc0317153 Move several vector intrinsics out of experimental namespace (#88748)
This patch is moving out following intrinsics:
* vector.interleave2/deinterleave2
* vector.reverse
* vector.splice

from the experimental namespace.

All these intrinsics exist in LLVM for more than a year now, and are
widely used, so should not be considered as experimental.
2024-04-29 10:16:45 +01:00
Jie Fu
da213d77c0 [MLIR] Fix linking error of PolynomialDialect on MacOS (NFC)
ld64.lld: error: undefined symbol: mlir::detail::verifyInferredResultTypes(mlir::Operation*)
>>> referenced by tools/mlir/lib/Dialect/Polynomial/IR/CMakeFiles/obj.MLIRPolynomialDialect.dir/PolynomialDialect.cpp.o:(symbol mlir::Op<mlir::polynomial::AddOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::Type>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::NOperands<2u>::Impl, mlir::OpTrait::OpInvariants, mlir::OpTrait::IsCommutative, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::OpTrait::SameOperandsAndResultType, mlir::OpTrait::Elementwise, mlir::OpTrait::Scalarizable, mlir::OpTrait::Vectorizable, mlir::OpTrait::Tensorizable, mlir::InferTypeOpInterface::Trait>::verifyRegionInvariants(mlir::Operation*)+0x14)
>>> referenced by tools/mlir/lib/Dialect/Polynomial/IR/CMakeFiles/obj.MLIRPolynomialDialect.dir/PolynomialDialect.cpp.o:(symbol mlir::Op<mlir::polynomial::MonicMonomialMulOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::Type>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::NOperands<2u>::Impl, mlir::OpTrait::OpInvariants, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::InferTypeOpInterface::Trait>::verifyRegionInvariants(mlir::Operation*)+0x14)
2024-04-29 09:39:55 +08:00
Jeremy Kun
145176dc0c polynomial: Add basic ops (#89525)
Adds a few basic polynomial ops.

- add, sub, mul
- mul_scalar
- leading_term, monomial_mul, monomial (useful for lowering `mul` to
standard MLIR)
- from_tensor, to_tensor, constant

---------

Co-authored-by: Jeremy Kun <j2kun@users.noreply.github.com>
Co-authored-by: Oleksandr "Alex" Zinenko <ftynse@gmail.com>
2024-04-28 14:58:44 -07:00
Christian Sigg
fac349a169 Reapply "[mlir] Mark isa/dyn_cast/cast/... member functions depreca… (#90406)
…ted. (#89998)" (#90250)

This partially reverts commit 7aedd7dc75.

This change removes calls to the deprecated member functions. It does
not mark the functions deprecated yet and does not disable the
deprecation warning in TypeSwitch. This seems to cause problems with
MSVC.
2024-04-28 22:01:42 +02:00
Théo Degioanni
216787cffc [mlir][arith] Add tests for i0 canonicalization (#89665)
Before #87193, the canonicalizer in arith crashed when attempting signed
extension on an i0 value. To hopefully avoid it happening again, this PR
introduces tests for canonicalization of arith operations with i0
values, focusing on operations related to bit width or signedness.
2024-04-28 19:26:31 +02:00
Renato Golin
4cec3b36f6 [MLIR][Linalg] More Linalg named ops (#90236)
Adding `min` that was already implemented but not exposed.

Adding a few additional unary ops:
* Reciprocal as `arith.div(1,arg)`
* Round as `math.round(arg)`
* Sqrt as `math.sqrt(arg)`
* Rsqrt as `math.rsqrt(arg)`
* Square as `math.powf(arg, 2)`
* TanH as `math.tanh(arg)`

All with the agreed semantics at the round table: no implicit
broadcast/type cast.
2024-04-28 15:25:24 +01:00
Fabian Mora
dc6ce60801 [mlir][gpu] Remove offloadingHandler from ModuleToBinary (#90368)
This patch removes the `offloadingHandler` option from the
`ModuleToBinary` pass. The option is removed as it cannot be parsed from
textual form.

This fixes issue #90344.
2024-04-28 10:03:12 -04:00
Semyon Khechnev
9145514fde [mlir][arith] fix canonicalization of mulsi_extended for i1 (#90150)
There is the `MulSIExtendedRHSOne` canonicalization for
arith.mulsi_extended that is defined as follows: `mulsi_extended(x, 1)
-> [x, extsi(cmpi slt, x, 0)]`. In the implementation of this, there is
a `IsScalarOrSplatOne` constraint for the second argument. However, this
constraint does not correctly handle situation when multiplying i1
values. Therefore, an additional constraint has been added which checks
the second argument for strict positivity.

fix #88732
2024-04-27 01:29:11 -04:00
dyung
7aedd7dc75 Revert "[mlir] Mark isa/dyn_cast/cast/... member functions deprecated. (#89998)" (#90250)
This reverts commit 950b7ce0b8.

This change is causing build failures on a bot
https://lab.llvm.org/buildbot/#/builders/216/builds/38157
2024-04-26 12:09:13 -07:00
Peiming Liu
3aeb28b93f [mlir][sparse] fold sparse convert into producer linalg op. (#89999) 2024-04-26 10:48:15 -07:00
Diego Caballero
571831a680 [mlir] Add sub-byte type emulation support for memref.collapse_shape (#89962)
This PR adds support for `memref.collapse_shape` to sub-byte type emulation. The `memref.collapse_shape` becomes a no-opt given that we are flattening the memref as part of the emulation (i.e., we are collapsing all the dimensions).
2024-04-26 17:29:06 +02:00
Jie Fu
64d514a2e1 [mlir] Fix -Wdeprecated-declarations of cast in VCIXToLLVMIRTranslation.cpp (NFC)
In file included from /llvm-project/mlir/lib/Target/LLVMIR/Dialect/VCIX/VCIXToLLVMIRTranslation.cpp:70:
/llvm-project/build-Release/tools/mlir/include/mlir/Dialect/LLVMIR/VCIXConversions.inc:8:48: error: 'cast' is deprecated: Use mlir::cast<U>() instead [-Werror,-Wdeprecated-declarations]
      VectorType vt = op.getResult().getType().cast<VectorType>();
                                               ^
/llvm-project/mlir/include/mlir/IR/Types.h:345:9: note: 'cast' has been explicitly marked deprecated here
U Type::cast() const {
        ^
In file included from /llvm-project/mlir/lib/Target/LLVMIR/Dialect/VCIX/VCIXToLLVMIRTranslation.cpp:70:
/llvm-project/build-Release/tools/mlir/include/mlir/Dialect/LLVMIR/VCIXConversions.inc:8:48: error: 'cast<mlir::VectorType>' is deprecated: Use mlir::cast<U>() instead [-Werror,-Wdeprecated-declarations]
      VectorType vt = op.getResult().getType().cast<VectorType>();
                                               ^
/llvm-project/mlir/include/mlir/IR/Types.h:112:5: note: 'cast<mlir::VectorType>' has been explicitly marked deprecated here
  [[deprecated("Use mlir::cast<U>() instead")]]
    ^
In file included from /llvm-project/mlir/lib/Target/LLVMIR/Dialect/VCIX/VCIXToLLVMIRTranslation.cpp:70:
/llvm-project/build-Release/tools/mlir/include/mlir/Dialect/LLVMIR/VCIXConversions.inc:32:48: error: 'cast' is deprecated: Use mlir::cast<U>() instead [-Werror,-Wdeprecated-declarations]
      VectorType vt = op.getResult().getType().cast<VectorType>();
                                               ^
/llvm-project/mlir/include/mlir/IR/Types.h:345:9: note: 'cast' has been explicitly marked deprecated here
U Type::cast() const {
        ^
In file included from /llvm-project/mlir/lib/Target/LLVMIR/Dialect/VCIX/VCIXToLLVMIRTranslation.cpp:70:
/llvm-project/build-Release/tools/mlir/include/mlir/Dialect/LLVMIR/VCIXConversions.inc:32:48: error: 'cast<mlir::VectorType>' is deprecated: Use mlir::cast<U>() instead [-Werror,-Wdeprecated-declarations]
      VectorType vt = op.getResult().getType().cast<VectorType>();
                                               ^
/llvm-project/mlir/include/mlir/IR/Types.h:112:5: note: 'cast<mlir::VectorType>' has been explicitly marked deprecated here
  [[deprecated("Use mlir::cast<U>() instead")]]
    ^
4 errors generated.
2024-04-26 23:26:44 +08:00
Christian Sigg
950b7ce0b8 [mlir] Mark isa/dyn_cast/cast/... member functions deprecated. (#89998)
See https://mlir.llvm.org/deprecation and
https://discourse.llvm.org/t/preferred-casting-style-going-forward.
2024-04-26 16:28:30 +02:00
Diego Caballero
450ac01bb9 [mlir][MemRef] Add ExtractStridedMetadataOpCollapseShapeFolder (#89954)
This PR adds a new pattern to the set of patterns used to resolve the offset, sizes and
stride of a memref. Similar to `ExtractStridedMetadataOpSubviewFolder`, the new
pattern resolves strided_metadata(collapse_shape) directly, without introduce a
reshape_cast op.
2024-04-26 16:20:24 +02:00
Troy Butler
468fecfc39 Fix mismatches between function parameter definitions and declarations (#89512)
Addresses issue #88716.

Some function parameter names in the affected header files did not match
the parameter names in the definitions, or were listed in a different
order.

---------

Signed-off-by: Troy-Butler <squintik@outlook.com>
2024-04-26 13:00:31 +02:00
Mehdi Amini
6844c2feae Revert 4 last "[mlir-lsp]" commits: pre-merge bot is broken
This reverts commits:
- f3f6f22dfc.
- 37e13d4924.
- ba1b52e6e7.
- 84bc21f910.
2024-04-25 19:21:39 -07:00
Brian Gesiak
a8c88de0df Revert "[mlir-lsp] Rename OutgoingNotification (NFC) (#90076)"
This reverts commit b77416ea15. While that seemed like an
appropriate rename at the time, further review on pull request #90078
makes it unnecessary. This revert changes the name back.
2024-04-25 21:59:22 -04:00
Rob Suderman
593f6fdcb4 [mlir][tensor] Fix tensor.reshape canonicalization (#90141)
Canonicalization defaulted to replacement when the input dims were from
unknown source. This is obviously incorrect. Tweaked and included test
to prevent future issue.
2024-04-25 17:41:12 -07:00
Prashant Kumar
8feedd5e06 [mlir][linalg] Fix the semantic use of a flag (#90081)
`useInBoundsInsteadOfMasking` was doing the opposite i.e., when set to
true; was updating the mask instead of updating the inBounds.
2024-04-26 05:39:00 +05:30
Zhaoshi Zheng
dbcc4549e6 [MLIR][Vector] Allow Scalable Dim in OneDimMultiReductionToTwoDim (#89978)
To correctly lower multi_reduction of 1-dim scalable vector, e.g., <[4]xf32>
2024-04-25 13:54:47 -07:00
Andrzej Warzyński
3005ca2159 [mlir][linalg] Add a test for inferConvolutionDimsImpl (#90057)
Adds a test for `inferConvolutionDimsImpl` to exercise the logic for
depthwise convs.
2024-04-25 21:25:31 +01:00
Brian Gesiak
b77416ea15 [mlir-lsp] Rename OutgoingNotification (NFC) (#90076)
Rename `OutgoingNotification` to `OutgoingMessage`, since the same
callback function type will be used in a future commit to represent
outgoing requests, in addition to outgoing notifications.
2024-04-25 15:39:55 -04:00