[Mlir-commits] [mlir] [MLIR] Add a utility pass to linearize `memref` (PR #136797)
Alan Li
llvmlistbot at llvm.org
Mon May 5 10:45:14 PDT 2025
lialan wrote:
> I don't think you can do that correctly if you're trying to linearize the index computation for a subview - or, even outside fo a subview, any strided memref
>
> Remember, every index in a `memref.load %m[%i0, %i1, ... %in] : memref<L0 x L1 ... x Ln x T, layout>` has to have `0 <= %i_k < L_k`. So if I have a `%m : memref<4x4xf32, strided<[8, 1]>>`, then if I determine the ultimate index of `%m[%i, %j]` to be `%j + 8 * %i` - which it is -, I need to allow for `0 <= %j + 8 * %i < 32`, because otherwise we'll break the memref.load invariants.
You are right here. Linearizing a subview is basically mixing strides of different dimensions into one dimension, it is possible it will fail.
So what do you say here, we fail if we cannot handle a subview?
https://github.com/llvm/llvm-project/pull/136797
More information about the Mlir-commits
mailing list