Repository navigation
Rewriter: don't crash fusing Relu/Clip chains when the Clip input has no type - #3102
Open
Kayvan Zahiri (Kayvan-Zahiri) wants to merge 1 commit into
Open
Kayvan Zahiri (Kayvan-Zahiri) wants to merge 1 commit into
Kayvan Zahiri (Kayvan-Zahiri) wants to merge 1 commit into
Conversation
… no type Signed-off-by: Kayvan Zahiri <kayvanandre@gmail.com>
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.
rewriter.rewrite()raises on a valid model when the input of a fused Clip has no type information, for example when shape inference hasn't been run:extract_min_maxread the dtype fromnode.inputs[0].dtype.numpy(), andx1.dtypeisNonehere. All three Clip rules (Clip/Clip, Clip/Relu, Relu/Clip) hit it, whether the bounds are initializers or Constant nodes.optimizer.optimize()doesn't, because it infers types first.The spec gives min and max the same type as the input, so the dtype now comes from the bounds when the input has none. The one case left without a dtype is
Clip(Relu(x))with no bounds and an untypedx. There,check()now fails the match instead of building a float64 min.Tests: a new class runs the three patterns on an untyped intermediate, without shape inference, and checks the no-bounds failure. All 4 tests fail on main with the error above. Rewriter tests: 414 passed.
test_fuse_pad_into_conv_6/_7fail on main too in my environment.Found while fuzzing the rewrite rules on untyped models, with Claude Code's help.