summaryrefslogtreecommitdiff
path: root/mlir/lib/Dialect
Commit message (Collapse)AuthorAgeFilesLines
* Remove sentinel argument from dispatchIndexOpFoldResults.Aliia Khasanova2022-12-136-77/+41
| | | | | | Post clean-up after merger of kDynamicSize and kDynamicStrideOrOffset. Differential Revision: https://reviews.llvm.org/D139929
* [mlir][scf] Fixes IndexSwitchOp verifier crashMehdi Amini2022-12-131-2/+5
| | | | Fixes #59460
* Apply clang-tidy fixes for readability-identifier-naming in ↵Mehdi Amini2022-12-131-23/+23
| | | | AsyncToAsyncRuntime.cpp (NFC)
* Apply clang-tidy fixes for performance-unnecessary-value-param in ↵Mehdi Amini2022-12-131-5/+7
| | | | AsyncToAsyncRuntime.cpp (NFC)
* [mlir][Vector] Initial masking support in Linalg vectorizerDiego Caballero2022-12-135-115/+571
| | | | | | | | | | | This patch introduces the initial bits to support vector masking using the `vector.mask` operation. Vectorization changes should be NFC for non-masked cases. We can't test masked cases directly until we extend the Transform dialect to support masking. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D137690
* [mlir][sparse] Simplifying SparseTensorEncodingAttr function argumentswren romano2022-12-124-22/+20
| | | | | | | | Since STEA isa Attribute, and that's just (a wrapper around) a pointer, the extra `const` and `&` aren't necessary for function arguments. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D139886
* [mlir][tosa] Refactor tosa.resizeRob Suderman2022-12-122-7/+6
| | | | | | | | | | | | Moved to using helper lambdas to avoid code repetition. IR needed to be reordered to accommodate which should be the only changes to the existing tests. This changes the quantized test to target `i48` types to guarantee types are extended correctly when necessary. Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D136500
* [mlir][Transform] Make FuseIntoContainingOp support rank-reducing extract slicesNicolas Vasilache2022-12-122-7/+38
| | | | | | This fixes an issue where rank-reducing + fusion would not interop properly. Differential Revision: https://reviews.llvm.org/D139844
* [mlir][arith] Simplify muli emulation with mului_extendedJakub Kuderski2022-12-121-64/+12
| | | | | | | | | Using `arith.mului_extended` makes it much simpler to emulate wide integer multiplication. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D139776
* [mlir][bufferize] Fix typo in EmptyTensorEliminationMatthias Springer2022-12-121-2/+2
| | | | | | | | | | | The structure of the code has changed a while ago and the code was not updated properly. There is no test case for this because we do currently not have an op that could trigger this bug. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D139838
* [mlir][bufferize] Implement BufferizableOpInterface for tensor.emptyMatthias Springer2022-12-123-1/+43
| | | | | | | | The op is not bufferizable but should be analyzable (for `EliminateEmptyTensors`, which uses the bufferization infrastructure). Also improve debugging functionality and error messages. Also adds a missing pass to the sparse pipeline. (tensor.empty should be replaced with bufferization.alloc_tensor, but it sometimes used to work without depending on how the tensor.empty is used. Now we always fail explicitly.)
* [mlir] make DiagnosedSilenceableError(LogicalResult) ctor privateAlex Zinenko2022-12-124-38/+36
| | | | | | | | | | Now we have more convenient functions to construct silenceable errors while emitting diagnostics, and the constructor is ambiguous as it doesn't tell whether the logical error is silencebale or definite. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D137257
* [mlir][Transform] NFC - Return omitted loop construct in ↵Nicolas Vasilache2022-12-121-1/+3
| | | | transform.tile_reduction_xxx ops
* [MLIR] Vectorize tensor.extract on n-D tensor (n >= 2)Andrzej Warzynski2022-12-122-30/+92
| | | | | | | | | | | | | | | | | | | | | | | This patch implements the vectorization of tensor.extract for arbitrary tensors. It basically extends https://reviews.llvm.org/D133786 by adding support for n-D tensors (n >= 2). This is implemented by essentially flattening the indices. When benchmarking the vectorized code, we have observed that it is slower than the scalar code. That's most likely due to sub-optimal (and, in general slow) gather loads. More work is needed to identify an implementation and/or a representation that would lead to better code. In the meantime, the vectorization of n-D tensors (where n >= 2) has to be explicitly enabled. This can be done either via: * transfer dialect's `vectorize_nd_extract` attribute, * dedicated bool argument in the `vectorize` method from "Vectorization.cpp". The second option was added to control the new functionality through means other than the transfer dialect. Related discussion: https://github.com/iree-org/iree/issues/9198 Differential Revision: https://reviews.llvm.org/D137660
* [mlir] fixes to transform::SequenceOpAlex Zinenko2022-12-121-9/+18
| | | | | | | | | | | | | | | | Harden the verifier to check that the block argument type matches the operand type, when present. This was overlooked when transform dialect types were introduced. Fix the builders to preserve the insertion point before creating the block, otherwise the insertion point is updated to be within the block by `createBlock` and never reset to be after the sequence op itself, leading all following operations to be created in the unexpected to the caller place. Reviewed By: chelini, springerm Differential Revision: https://reviews.llvm.org/D139427
* [mlir][affine] Fix crash in AffineApplyOp canonicalizationMatthias Springer2022-12-121-7/+12
| | | | | | | | | This test case used to crash with a failed assertion: ``` AffineExpr.cpp:659 in AffineExpr simplifyMul(AffineExpr, AffineExpr): lhs.isSymbolicOrConstant() || rhs.isSymbolicOrConstant() ``` This was caused by combining two affine maps, which created a multiplication of two non-symbols.
* NFC. Refactor/update some affine fusion pass code for readabilityUday Bondhugula2022-12-122-53/+54
| | | | | | | | | NFC. Refactor some affine fusion pass code for readability. Some of its methods are too long. This is the first among some NFC changes before new features/related updates are posted. Add missing code comments at a couple of places. Differential Revision: https://reviews.llvm.org/D139255
* [mlir] Use std::optional instead of None in comments (NFC)Kazu Hirata2022-12-101-2/+2
| | | | | | | This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
* [mlir] FunctionOpInterface: turn required attributes into interface methods ↵Jeff Niu2022-12-109-51/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Reland) Reland D139447, D139471 With flang actually working - FunctionOpInterface: make get/setFunctionType interface methods This patch removes the concept of a `function_type`-named type attribute as a requirement for implementors of FunctionOpInterface. Instead, this type should be provided through two interface methods, `getFunctionType` and `setFunctionTypeAttr` (*Attr because functions may use different concrete function types), which should be automatically implemented by ODS for ops that define a `$function_type` attribute. This also allows FunctionOpInterface to materialize function types if they don't carry them in an attribute, for example. Importantly, all the function "helper" still accept an attribute name to use in parsing and printing functions, for example. - FunctionOpInterface: arg and result attrs dispatch to interface This patch removes the `arg_attrs` and `res_attrs` named attributes as a requirement for FunctionOpInterface and replaces them with interface methods for the getters, setters, and removers of the relevent attributes. This allows operations to use their own storage for the argument and result attributes. Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D139736
* [Transforms] Use std::optional in AsyncToAsyncRuntime.cpp (NFC)Kazu Hirata2022-12-101-1/+2
| | | | | | | This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
* [Transforms] Use std::optional in LoopFusion.cpp (NFC)Kazu Hirata2022-12-101-5/+6
| | | | | | | This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
* [Analysis] Use std::optional in LoopAnalysis.cpp (NFC)Kazu Hirata2022-12-101-1/+2
| | | | | | | This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
* [Analysis] Use std::optional in AffineStructures.cpp (NFC)Kazu Hirata2022-12-101-1/+2
| | | | | | | This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
* [mlir][arith] Define mulsi_extended opJakub Kuderski2022-12-092-0/+57
| | | | | | | | | | | | Extend D139688 with the signed version of the extended multiplication op. Add conversion to the SPIR-V and LLVM dialects. This was originally proposed in: https://discourse.llvm.org/t/rfc-arith-add-extended-multiplication-ops/66869. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D139743
* [mlir][sparse] avoid sorting when unnecessary when convert sparse tensors.Peiming Liu2022-12-101-24/+55
| | | | | | Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D139744
* [mlir][arith] Define mului_extended opJakub Kuderski2022-12-092-1/+67
| | | | | | | | | | | Add conversion to the SPIR-V and LLVM dialects. This was originally proposed in: https://discourse.llvm.org/t/rfc-arith-add-extended-multiplication-ops/66869. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D139688
* [mlir][arith] Add canon pattern: addui_extended -> addiJakub Kuderski2022-12-092-0/+16
| | | | | | | | | Demote `arith.addui_extended` to `arith.addi` when the 'overflow' result has no uses. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D139722
* [mlir][Linalg] Apply fixes to TileReductionUsingForeachThreadOpNicolas Vasilache2022-12-093-76/+142
| | | | | | | In the process, numerous insertion point issues were found and fixed. RAII on insertion points is now used more dilligently. Differential Revision: https://reviews.llvm.org/D139714
* Revert "[mlir] FunctionOpInterface: make get/setFunctionType interface methods"David Spickett2022-12-099-41/+37
| | | | | | | | | and "[mlir] Fix examples build" This reverts commit fbc253fe81da4e1d6bfa2519e01e03f21d8c40a8 and 96cf183bccd7d1c3083f169a89a6af1f263b3aae. Which I missed in the first revert in f3379feabe38fd3711b13ffcf6de4aab03b7ccdc.
* Revert "[mlir] FunctionOpInterface: arg and result attrs dispatch to interface"David Spickett2022-12-098-57/+35
| | | | | | | | and "[flang] Fix flang after MLIR update" This reverts commit dd74e6b6f4fb7a4685086a4895c1934e043f875b and 1897b67ae86470ad54f6baea6f220933d8053b5b due to ongoing test failures on flang bots e.g. https://lab.llvm.org/buildbot/#/builders/179/builds/5050
* [mlir][linalg] Fold duplicate and unused inputs in linalg.genericMatthias Springer2022-12-091-6/+70
| | | | | | If an input bbArg is not used, its corresponding input operand is removed. If there are duplicate input operands or input operands that are also used as output operands, the duplicate input operands are removed. Output operands are never modified. Differential Revision: https://reviews.llvm.org/D139709
* [mlir][bufferize] Improve analysis of external functionsMatthias Springer2022-12-092-35/+86
| | | | | | | | External functions have no body, so they cannot be analyzed. Assume conservatively that each tensor bbArg may be aliasing with each tensor result. Furthermore, assume that each function arg is read and written-to after bufferization. This default behavior can be controlled with `bufferization.access` (similar to `bufferization.memory_layout`) in test cases. Also fix a bug in the dialect attribute verifier, which did not run for region argument attributes. Differential Revision: https://reviews.llvm.org/D139517
* [mlir] Support llvm.readonly attribute on llvm pointersGuray Ozen2022-12-091-0/+9
| | | | | | | | The attribute is translated into LLVM's function attribute 'readonly'. The attribute can be only used for pointers. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D139641
* [mlir][sparse] reject kernels with non-sparsfiable reduction expression.Peiming Liu2022-12-082-0/+139
| | | | | | | | | | | | To address https://github.com/llvm/llvm-project/issues/59394. Reduction on negation of the output tensor is a non-sparsifiable kernel, it creates cyclic dependency. This patch reject those cases instead of crashing. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D139659
* [mlir] FunctionOpInterface: arg and result attrs dispatch to interfaceJeff Niu2022-12-088-35/+57
| | | | | | | | | | | | | | This patch removes the `arg_attrs` and `res_attrs` named attributes as a requirement for FunctionOpInterface and replaces them with interface methods for the getters, setters, and removers of the relevent attributes. This allows operations to use their own storage for the argument and result attributes. Depends on D139471 Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D139472
* [mlir] FunctionOpInterface: make get/setFunctionType interface methodsJeff Niu2022-12-089-37/+41
| | | | | | | | | | | | | | | | | | | This patch removes the concept of a `function_type`-named type attribute as a requirement for implementors of FunctionOpInterface. Instead, this type should be provided through two interface methods, `getFunctionType` and `setFunctionTypeAttr` (*Attr because functions may use different concrete function types), which should be automatically implemented by ODS for ops that define a `$function_type` attribute. This also allows FunctionOpInterface to materialize function types if they don't carry them in an attribute, for example. Importantly, all the function "helper" still accept an attribute name to use in parsing and printing functions, for example. Reviewed By: rriddle, lattner Differential Revision: https://reviews.llvm.org/D139447
* [mlir][linalg] Print broadcast, map, reduce, transpose ins/outs on one line.Alexander Belyaev2022-12-081-16/+5
| | | | Differential Revision: https://reviews.llvm.org/D139650
* [mlir][sparse] Fix problems in creating complex zero for initialization.bixia12022-12-083-7/+5
| | | | | | Reviewed By: aartbik, wrengr Differential Revision: https://reviews.llvm.org/D139591
* [mlir][ExpandStridedMetadata] Handle collapse_shape of dim of size 1 gracefullyQuentin Colombet2022-12-081-8/+44
| | | | | | | | | | | | | | | | | | | | | | | | Collapsing dimensions of size 1 with random strides (a.k.a. non-contiguous w.r.t. collapsed dimensions) is a grey area that we'd like to clean-up. (See https://reviews.llvm.org/D136483#3909856) That said, the implementation in `memref-to-llvm` currently skips dimensions of size 1 when computing the stride of a group. While longer term we may want to clean that up, for now matches this behavior, at least in the static case. For the dynamic case, for this patch we stick to `min(group strides)`. However, if we want to handle the dynamic cases correctly while allowing non-truly-contiguous dynamic size of 1, we would need to `if-then-else` every dynamic size. In other words `min(stride_i, for all i in group and dim_i != 1)`. I didn't implement that in this patch at the moment since `memref-to-llvm` is technically broken in the general case for this. (It currently would only produce something sensible for row major tensors.) Differential Revision: https://reviews.llvm.org/D139329
* [mlir] Use std::nullopt instead of None in comments (NFC)Kazu Hirata2022-12-073-8/+9
| | | | | | | This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
* [mlir][sparse] introduce sparse vectorization to the sparse compiler pipelineAart Bik2022-12-073-5/+42
| | | | | | Reviewed By: Peiming Differential Revision: https://reviews.llvm.org/D139581
* [mlir][sparse] Add dependence on bufferization.bixia12022-12-071-0/+5
| | | | | | Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D139571
* [mlir][arith] Fix comment typo. NFC.Jakub Kuderski2022-12-071-1/+1
|
* [mlir][arith] Rename addui_carry to addui_extendedJakub Kuderski2022-12-072-32/+34
| | | | | | | | | | | | The goal is to make the naming of the future `_extended` ops more consistent. With unsigned addition, the carry value/flag and overflow bit are the same, but this is not true when it comes to signed addition. Also rename the second result from `carry` to `overflow`. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D139569
* [mlir] Make patterns for folding tensor.empty optional.Alexander Belyaev2022-12-074-55/+82
| | | | | | | | | | At the moment, they are a part of EmptyOp::getCanonicalizationPatterns. When extract_slice(tensor.empty) is rewritten as a new tensor.empty, it could happen that we end up with two tensor.empty ops, since the original tensor.empty can have two users. After bufferization such cases result in two allocations. Differential Revision: https://reviews.llvm.org/D139308
* [mlir] Add hoisting of transfer ops in affine loopsJavier Setoain2022-12-071-11/+39
| | | | | | | | The only way to do this with the current hoisting strategy is by lowering Affine to Scf first, but that prevents further passes on Affine. Differential Revision: https://reviews.llvm.org/D137600
* [mlir][sparse] Improve concatenate operation conversion for the case with ↵bixia12022-12-071-26/+69
| | | | | | | | annotated all dense result. Reviewed By: aartbik Differential Revision: https://reviews.llvm.org/D139345
* [mlir][linalg] Add extra parameter to tiling reduction to foreach_threadThomas Raoux2022-12-072-153/+163
| | | | | | | This adds a tile_size parameter, when it is used the tiles are cyclically distributed onto the threads of the scf.foreach_thread op. Differential Revision: https://reviews.llvm.org/D139474
* [mlir][tensor] Support parallel_insert_slice in reassociative reshape folderMatthias Springer2022-12-071-11/+12
| | | | Differential Revision: https://reviews.llvm.org/D139540
* [mlir][NFC] Add a new getStridesAndOffset functionQuentin Colombet2022-12-072-40/+7
| | | | | | | | | | | | | The new function is a wrapper around the regular `getStridesAndOffset` that offers a more compact way (as in writing less code) of getting the relevant information. This method is intended to be used only when it is known that the LogicalResult of the regular `getStridesAndOffset` must be "succeeded". This warpper will assert on that. Differential Revision: https://reviews.llvm.org/D139529