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:

  1. As in the documentation for tensor.dim, the usage of the tensor namespace has been (mistakenly?) replaced with memref:
// 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?

  1. Assuming the above are typos, the first example is accepted by mlir-opt when replacing the memref namespace with the tensor namespace. However, the second example fails to allow nesting the tensor 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