MLIR Op operand constraints


Is there a way to specify that a particular operand (input) to an Op can only be the result of a specific set of Ops itself? Obviously we can impose type constraints in the td file, but we’re wondering if those constraints can be further hardened to specific Ops and hopefully prevent rewrites on the subgraphs that would violate those constraints.

Thanks in advance,

If this is really a constraint of the Operation itself, is it in scope for the verifier for this op?

Note that this may be fragile, as it limits the ability for these other ops to fold or rewrite themselves: in general we consider an SSA value for a given type to be “self-contained”: you can substitute the producer for any other op that produce the same value.

You might want to consider an op with a region that encodes the entire dependency within a single operation if that is possible.