[all-commits] [llvm/llvm-project] 64f998: [mlir][ExpandStridedMetadata] Handle collapse_shap...

qcolombet via All-commits all-commits at lists.llvm.org
Wed Dec 7 23:41:57 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 64f99842a6c03fdb57349fcaed3f4821ef612ed1
      https://github.com/llvm/llvm-project/commit/64f99842a6c03fdb57349fcaed3f4821ef612ed1
  Author: Quentin Colombet <quentin.colombet at gmail.com>
  Date:   2022-12-08 (Thu, 08 Dec 2022)

  Changed paths:
    M mlir/lib/Dialect/MemRef/Transforms/ExpandStridedMetadata.cpp
    M mlir/test/Dialect/MemRef/expand-strided-metadata.mlir

  Log Message:
  -----------
  [mlir][ExpandStridedMetadata] Handle collapse_shape of dim of size 1 gracefully

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




More information about the All-commits mailing list