[3/N Dynamic Shapes] Support inferring dynamic dims from inputs -> outputs in inferPropertiesNode#416
Conversation
c46c643 to
d2fa3d1
Compare
| for (auto &output : outputs) | ||
| inferSameShapeDynamicDimsFromInputs(output, inputs); |
There was a problem hiding this comment.
@IanWood1 is this safe to do for custom ops? It copies dynamic dims from an input whose representative getDim() exactly equals the already-specified output getDim(), and it skips outputs that already have dynamic dims. But even then I'm skeptical we want this here. I'd rather avoid inferring dynamic dims for custom ops and instead have users annotate, since custom ops are opaque and can be doing stuff we don't control. I doubt we infer shapes/strides for custom ops too so this seems unnecessary. Thoughts?
There was a problem hiding this comment.
Yeah, the user has to specify this (they already have to state the output shape).
Why is inferSameShapeDynamicDimsFromInputs more complicated than just copying the dynamic dims from input to output?
There was a problem hiding this comment.
just copying the dynamic dims from input to output?
This assumes the custom operation preserves the layout of inputs (kind of like pointwise ops) and there's no reduction / permutation / expansion which is difficult to guarantee. This utility was doing a (not great) compromise of inferring dynamic dims based on a match in the representative dims between inputs and outputs.
1132c73 to
2890730
Compare
d828807 to
6e71ea0
Compare
Signed-off-by: Sambhav Jain <sambhav@alumni.stanford.edu>
Signed-off-by: Sambhav Jain <sambhav@alumni.stanford.edu>
Adds dynamic dimension inference for inferPropertiesNode so output tensors inherit compatible dynamic annotations from their inputs without requiring callers to restate them.
This also updates dynamic shape samples and focused node/lit coverage to assert inferred output dynamic dims across broadcast, same-shape, reduction, convolution, matmul, norm, SDPA, and custom-op flows.
Co-authored-by: GPT 5.5 codex@openai.com
🤖 Generated with Codex