[Mlir-commits] [mlir] [mlir] Change `tensor.extract/insert` to take static/dynamic indices. (PR #104488)
Matthias Springer
llvmlistbot at llvm.org
Fri Aug 16 00:10:18 PDT 2024
================
@@ -332,12 +332,37 @@ def Tensor_ExtractOp : Tensor_Op<"extract", [
```mlir
%4 = tensor.extract %t[%1, %2] : tensor<4x4xi32>
%5 = tensor.extract %rt[%1, %2] : tensor<?x?xi32>
+ %6 = tensor.extract %rt[3, 4] : tensor<?x?xi32>
+ %7 = tensor.extract %rt[%1, 4] : tensor<?x?xi32>
```
}];
- let arguments = (ins AnyRankedTensor:$tensor, Variadic<Index>:$indices);
+ let arguments = (ins
+ AnyRankedTensor:$tensor,
+ Variadic<Index>:$indices,
+ DenseI64ArrayAttr:$static_indices
+ );
let results = (outs AnyType:$result);
- let assemblyFormat = "$tensor `[` $indices `]` attr-dict `:` type($tensor)";
+ let assemblyFormat = [{
+ $tensor ``
+ custom<DynamicIndexList>($indices, $static_indices)
+ attr-dict `:` type($tensor)
+ }];
+
+ let builders = [
+ // Build an ExtractOp with mixed static and dynamic indexes.
+ OpBuilder<(ins "Value":$tensor, "ArrayRef<OpFoldResult>":$indexes,
+ CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)>,
+ // Build an ExtractOp with mixed static, dynamic indexes and inferred result type.
+ OpBuilder<(ins "Type":$resultType, "Value":$tensor, "ArrayRef<OpFoldResult>":$indexes,
+ CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)>,
+ // Build an ExtractOp with dynamic indexes.
----------------
matthias-springer wrote:
There are some spelling inconsistences: `indexes`, `indices`
https://github.com/llvm/llvm-project/pull/104488
More information about the Mlir-commits
mailing list