Repository navigation
fix(plugins): lower floor division in generated plugin output shapes - #4876
Open
narendasan wants to merge 1 commit into
Open
narendasan wants to merge 1 commit into
narendasan wants to merge 1 commit into
Conversation
This was referenced Oct 19, 2026
A custom op whose fake kernel sizes an output as a fraction of an input dimension -- `x.new_empty(..., x.shape[-1] // 2)` -- could not be turned into a plugin when that dimension is dynamic. Torch writes the size as its own sympy `FloorDiv`, `sympy.lambdify` prints unknown functions by name, and the generated shape function raised `NameError: name 'FloorDiv' is not defined` inside `get_output_data_types()`, which TensorRT reports as a failed `addPluginV3`. Lambdify the output shapes against a namespace that implements `FloorDiv` as `operator.floordiv`, which `tensorrt.plugin.ShapeExpr` supports (and plain ints, for static sizes). Tests: `tests/py/dynamo/automatic_plugin/test_automatic_plugin_shape_exprs.py` compiles an op returning the sum of the two halves of a dynamic last dim and checks shapes and values at the min/opt/max sizes (odd sizes included); it fails without the change. `pytest tests/py/dynamo/automatic_plugin`: 34 passed, 2 skipped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
narendasan
force-pushed
the
narendasan/plugin-shape-floordiv
branch
from
November 23, 2026 23:06
06d08e2 to
dfe7174
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
//-- e.g.x.new_empty((*x.shape[:-1], x.shape[-1] // 2))-- could not be turned into an automatically generated plugin. Torch writes the size as its own sympyFloorDiv,sympy.lambdifyprints unknown functions by name, and the generated shape function raisedNameError: name 'FloorDiv' is not definedinsideget_output_data_types(), which TensorRT reports as a failedaddPluginV3.FloorDivasoperator.floordiv, whichtensorrt.plugin.ShapeExprsupports (as do plain ints, for static sizes).Tests
tests/py/dynamo/automatic_plugin/test_automatic_plugin_shape_exprs.py: compiles an op returning the sum of the two halves of a dynamic last dim and checks shapes and values at the min/opt/max sizes (odd sizes included). It fails without the change, with theNameErrorabove.pytest tests/py/dynamo/automatic_plugin: 34 passed, 2 skipped.pytest tests/py/kernels tests/py/dynamo/automatic_plugin/test_automatic_plugin_shape_exprs.pygives 250 passed, 34 skipped.🤖 Generated with Claude Code