[all-commits] [llvm/llvm-project] b91d5a: [MLIR][Vector] Allow any strided memref for one-el...

Twice via All-commits all-commits at lists.llvm.org
Sun Jan 12 08:03:03 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b91d5af1ac3ad2c18b1dfde2061a6ac1d638e6e4
      https://github.com/llvm/llvm-project/commit/b91d5af1ac3ad2c18b1dfde2061a6ac1d638e6e4
  Author: Twice <twice at apache.org>
  Date:   2025-01-12 (Sun, 12 Jan 2025)

  Changed paths:
    M mlir/lib/Dialect/Vector/Transforms/LowerVectorGather.cpp
    M mlir/test/Dialect/Vector/vector-gather-lowering.mlir

  Log Message:
  -----------
  [MLIR][Vector] Allow any strided memref for one-element vector.load in lowering vector.gather (#122437)

In `Gather1DToConditionalLoads`, currently we will check if the stride
of the most minor dim of the input memref is 1. And if not, the
rewriting pattern will not be applied. However, according to the
verification of `vector.load` here:

https://github.com/llvm/llvm-project/blob/4e32271e8b304eb018c69f74c16edd1668fcdaf3/mlir/lib/Dialect/Vector/IR/VectorOps.cpp#L4971-L4975

.. if the output vector type of `vector.load` contains only one element,
we can ignore the requirement of the stride of the input memref, i.e.
the input memref can be with any stride layout attribute in such case.

So here we can allow more cases in lowering `vector.gather` by relaxing
such check.

As shown in the test case attached in this patch
[here](https://github.com/llvm/llvm-project/blob/1933fbad58302814ccce5991a9320c0967f3571b/mlir/test/Dialect/Vector/vector-gather-lowering.mlir#L151),
now `vector.gather` of memref with non-trivial stride can be lowered
successfully if the result vector contains only one element.

---------

Signed-off-by: PragmaTwice <twice at apache.org>
Co-authored-by: Andrzej WarzyƄski <andrzej.warzynski at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list