Add support for PyTorch non-finite predicates - #2834
Open
binaydhakal wants to merge 3 commits into
Open
Conversation
TobyRoseman
requested changes
Aug 25, 2026
Signed-off-by: Binaya Dhakal <binaydhakal35@gmail.com>
Collaborator
Collaborator
|
There are CI failures. Please take a look. It seems some of the model aren't valid for EXECUTORCH, in which case you should skip those tests for that frontend. There are lots of examples of that in the same test file. |
Signed-off-by: Binaya Dhakal <binaydhakal35@gmail.com>
Contributor
Author
|
Thanks @TobyRoseman, the remaining PR-related failures were the four complex-input cases under the ExecuTorch frontend. Local validation:
|
Collaborator
Contributor
Author
|
It passed this time @TobyRoseman . Thank you so much for your help and guidance. |
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
Add PyTorch frontend support for:
torch.isinftorch.isfinitetorch.isposinftorch.isneginfThe lowering compares floating-point inputs with dtype-matched positive and negative infinity constants. This avoids arithmetic-based detection that can misclassify very large finite FP32 values when FLOAT16 compute precision is enabled.
The implementation also preserves PyTorch semantics for FP16, integer, and boolean tensors.
isinfandisfinitesupport complex values by evaluating their real and imaginary components; PyTorch itself rejects the signed-infinity predicates for complex inputs.Both TorchScript and Torch Export are covered.
Testing
TestNanToNumregression casesAll tests passed on macOS.