[Mlir-commits] [mlir] [mlir][tensor] Preserve encoding in more canonicalizers (concat, reshape, pad) (PR #207241)

Dmitrii Makarenko llvmlistbot at llvm.org
Fri Jul 17 07:02:03 PDT 2026


Devjiu wrote:

@joker-eph

Right - folding an SSA size into the type means the verifier now checks what it couldn't before, and the pattern has to keep that valid.

For `VerifiableTensorEncoding`, `propagateEncoding` does exactly that: it runs `verifyEncoding` against the *refined* (more-static) shape - the one the verifier will now see - and drops the encoding if it no longer holds, so we can't emit invalid IR.

For opaque encodings there's nothing to check, but there's also nothing upstream *can* check: `RankedTensorType::verify` has no predicate for them, so they never make the type invalid regardless. Whether the metadata is still semantically right is the downstream's call - not implementing the interface is effectively the opt-out ("shape-agnostic / I own correctness").

Concrete proposal to unblock:
1. keep propagation for the insert-a-new-cast case ([this PR](https://github.com/llvm/llvm-project/pull/207239));
2. document the contract on `VerifiableTensorEncoding`: implement it =
   upstream verifies on transforms; don't = propagated as-is, author owns it.

If you'd rather bail out for opaque encodings by default, I can leave that - but it silently drops valid metadata in the common case. WDYT?

https://github.com/llvm/llvm-project/pull/207241


More information about the Mlir-commits mailing list