Skip to content

[3/N Dynamic Shapes] Support inferring dynamic dims from inputs -> outputs in inferPropertiesNode#416

Draft
sjain-stanford wants to merge 2 commits into
mainfrom
users/sambhav/dynamic-dim-output-inference
Draft

[3/N Dynamic Shapes] Support inferring dynamic dims from inputs -> outputs in inferPropertiesNode#416
sjain-stanford wants to merge 2 commits into
mainfrom
users/sambhav/dynamic-dim-output-inference

Conversation

@sjain-stanford
Copy link
Copy Markdown
Member

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

@sjain-stanford sjain-stanford force-pushed the users/sambhav/dynamic-dim-output-inference branch from c46c643 to d2fa3d1 Compare May 12, 2026 21:26
Comment thread include/fusilli/node/custom_op_node.h Outdated
Comment on lines +105 to +106
for (auto &output : outputs)
inferSameShapeDynamicDimsFromInputs(output, inputs);
Copy link
Copy Markdown
Member Author

@sjain-stanford sjain-stanford May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in d828807.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sjain-stanford sjain-stanford force-pushed the users/sambhav/tensor-dynamic-dims branch 2 times, most recently from 1132c73 to 2890730 Compare May 12, 2026 23:57
Base automatically changed from users/sambhav/tensor-dynamic-dims to main May 13, 2026 00:54
@sjain-stanford sjain-stanford force-pushed the users/sambhav/dynamic-dim-output-inference branch from d828807 to 6e71ea0 Compare May 13, 2026 21:11
Signed-off-by: Sambhav Jain <sambhav@alumni.stanford.edu>
Signed-off-by: Sambhav Jain <sambhav@alumni.stanford.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants