[Mlir-commits] [mlir] [mlir][linalg] Skip rank reduction for unsigned-cast contractions (PR #225993)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Oct 1 21:58:01 PDT 2026
================
@@ -963,6 +963,14 @@ struct RankReduceContractionOps : OpRewritePattern<FromOpTy> {
return rewriter.notifyMatchFailure(
contractionOp, "ops with user-defined maps are not supported");
}
+ // linalg.matmul is the only target op with a `cast` attribute.
+ if constexpr (!std::is_same_v<ToOpTy, MatmulOp>) {
+ auto castAttr = dyn_cast_if_present<TypeFnAttr>(
+ contractionOp->getInherentAttr("cast").value_or(Attribute()));
+ if (castAttr && castAttr.getValue() != TypeFn::cast_signed)
+ return rewriter.notifyMatchFailure(
+ contractionOp, "target op cannot represent a non-signed cast");
+ }
----------------
speryt wrote:
Done. I've decided to use `getCast()` instead of `getCastAttr()` which as I understand returns the cast_signed default when the attribute is absent, so no null check is needed.
https://github.com/llvm/llvm-project/pull/225993
More information about the Mlir-commits
mailing list