Hello, I’m trying to vectorize the following IR using:
-affine-simplify-structures -affine-super-vectorize="virtual-vector-size=8 test-fastest-varying=0"
module {
func.func @func_failing() -> i32 {
%c0 = arith.constant 0 : index
%alloc = memref.alloc() : memref<16x16xi32>
%subview = memref.subview %alloc[0, 0] [8, 16] [1, 1] : memref<16x16xi32> to memref<8x16xi32, strided<[16, 1]>>
affine.for %i = 0 to 8 {
affine.for %j = 0 to 8 {
%val = affine.load %subview[%i, %j] : memref<8x16xi32, strided<[16, 1]>>
affine.store %val, %subview[%i, %j] : memref<8x16xi32, strided<[16, 1]>>
}
}
%result = affine.load %subview[%c0, %c0] : memref<8x16xi32, strided<[16, 1]>>
memref.dealloc %alloc : memref<16x16xi32>
return %result : i32
}
}
However, the vectorization is failing with the following error:
error: NYI: non-trivial layout map
%val = affine.load %subview[%i, %j] : memref<8x16xi32, strided<[16, 1]>>
^
I tried modifying this check with the following code, and it resolves the issue for me:
if (auto layout = dyn_cast<AffineMapAttr>(memRefType.getLayout()))
if (!layout.getAffineMap().isIdentity())
return memoryOp.emitError("NYI: non-trivial layout map"), false;
Question:
Should I be adding more checks for strided layouts to ensure that I’m not violating any vectorization constraints?
If yes, How should I handle dynamic stride from strided layout and dynamic size?
Thanks!