[Mlir-commits] [mlir] [mlir] Compose expand of collapse to cast (PR #172864)
Maya Amrami
llvmlistbot at llvm.org
Wed Dec 24 00:15:40 PST 2025
================
@@ -748,14 +748,18 @@ bool CastOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
// source memref is static and the value in the target memref is the
// same. They are also compatible if either one is dynamic (see
// description of MemRefCastOp for details).
+ // Note that for dimensions of size 1, the stride can differ.
auto checkCompatible = [](int64_t a, int64_t b) {
return (ShapedType::isDynamic(a) || ShapedType::isDynamic(b) || a == b);
};
if (!checkCompatible(aOffset, bOffset))
return false;
- for (const auto &aStride : enumerate(aStrides))
- if (!checkCompatible(aStride.value(), bStrides[aStride.index()]))
+ for (const auto &[index, aStride] : enumerate(aStrides)) {
+ if (aT.getDimSize(index) == 1)
----------------
amrami wrote:
This is valid for all dimensions.
Adding another lit test that shows the mismatch in strides when the dimension is internal.
https://github.com/llvm/llvm-project/pull/172864
More information about the Mlir-commits
mailing list