Invalid reference to memref.gather and nested tensors in tensor dialect documentation? (original) (raw)
December 8, 2024, 1:23am 1
Follow-up to discussion of tensor dialect documentation.
There are two issues:
- As in the documentation for
tensor.dim
, the usage of thetensor
namespace has been (mistakenly?) replaced withmemref
:
// memref<?x4x1xf32> is a contiguous buffer of ?x4x1 elements.
// gather from random source slices must copy to the contiguous output.
%out = memref.gather %source[%indices] gather_dims([1]) :
(memref<4x4xf32>, memref<?x 1xindex>) -> memref<?x 4x1xf32>
// Nested buffer support would allow gather to directly index into the
// source buffer (i.e. represent a jagged view into the source).
%out = memref.gather %source[%indices] gather_dims([1]) :
(memref<4x4xf32>, memref<?x 1xindex>) -> memref<? x memref<4x1xf32>>
I assume this is another set of typos in the example, but perhaps this was done for demonstrative purposes?
- Assuming the above are typos, the first example is accepted by
mlir-opt
when replacing thememref
namespace with thetensor
namespace. However, the second example fails to allow nesting thetensor
type as the element type for the result tensor:
tensor_gather_4.mlir:10:83: error: invalid tensor element type
func.func @test(%t: tensor<4x4xf32>, %indices: tensor<?x1xindex>) -> tensor<?xtensor<4x1xf32>>
^
Have the semantics around nested tensor
types changed?
Best,
Gio