[Mlir-commits] [mlir] [mlir][tensor] Verify that `tensor.pad` padding is non-negative (PR #231389)
Mehdi Amini
llvmlistbot at llvm.org
Tue Oct 13 10:49:17 PDT 2026
joker-eph wrote:
> If we want (and we want to) cover dynamic pad, e.g.,
>
> %c-1 = arith.constant -1 : index
> %padded = tensor.pad %arg0 low[%c-1, 2] high[3, 4] { ... }
> after canonicalization it becomes low[-1, ...] and is rejected, so --tosa-to-tensor --canonicalize would fail.
This is very usual for these cases, and this is surfacing a major problem with these ops that are trying to accept, for the same thing, both an SSA value and an attribute: this an anti-pattern IMO and we should steer away from this.
On such an operation:
- The dynamic case (SSA value) cannot be checked by the verifier (according to MLIR verifier guidelines): any constraint here has to be something like UB.
- If you decide to statically verify the attribute in the verifier, then you push the complexity on the folder that is folding an SSA constant value into the attribute. Must check the verifier condition and often duplicate the check
- If you decide to not statically verify the attribute, the lowering needs to be resilient, but usually it's not that much of a problem because of the dynamic case anyway.
Having only SSA value simplifies all of this and keeps it all uniform.
https://github.com/llvm/llvm-project/pull/231389
More information about the Mlir-commits
mailing list