Skip to content

Use the promoted output dtype when lowering clamp - #83

Open
devin-lai wants to merge 1 commit into
apple:mainfrom
devin-lai:fix/clamp-type-promotion
Open

Use the promoted output dtype when lowering clamp#83
devin-lai wants to merge 1 commit into
apple:mainfrom
devin-lai:fix/clamp-type-promotion

Conversation

@devin-lai

Copy link
Copy Markdown

PyTorch promotes integer inputs when clamp bounds are floating point. The lowering instead built bounds in the input dtype, truncating their values and producing a result that disagreed with the exported node's declared type.

This uses the node output type as the working type, casting the input and tensor bounds when needed. The tests cover scalar and tensor float bounds while retaining the existing integer behavior

Tested with pytest -q tests/ops/test_ops.py::test_clamp

PyTorch promotes integer inputs when clamp bounds are floating point. The lowering instead built the bounds in the input type, truncating their values and producing a result that disagreed with the exported node's declared type.

Use the node output type as the working type, cast the input and tensor bounds when needed, and build scalar bounds in that type. Extend the end-to-end clamp coverage across scalar and tensor float bounds while retaining integer behavior.
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.

1 participant