[BugFix][Relax] Add legalize for isnan, isinf, isfinite#19492
Open
as4230 wants to merge 1 commit intoapache:mainfrom
Open
[BugFix][Relax] Add legalize for isnan, isinf, isfinite#19492as4230 wants to merge 1 commit intoapache:mainfrom
as4230 wants to merge 1 commit intoapache:mainfrom
Conversation
The Relax ops `relax.isnan`, `relax.isinf`, and `relax.isfinite` are
registered in the op registry and emit valid IR, but lack FLegalize
entries so LegalizeOps() leaves them unlowered and relax.build()
crashes at codegen with:
InternalError: CodeGenVM cannot handle this intrinsic now:
Op(relax.isnan)
Same crash on `isinf` and `isfinite`, on both LLVM and CUDA targets.
The TOPI implementations already exist (python/tvm/topi/math.py).
The fix is three register_legalize calls following the _call_topi_without_attr
pattern used by the other unary ops in the same file.
Fixes apache#19452.
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds legalization support for the unary operations isfinite, isinf, and isnan in the Relax framework, mapping them to their corresponding TOPI implementations. It also includes unit tests to verify the legalization of these operations for float32 tensors. I have no feedback to provide.
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.
The Relax ops
relax.isnan,relax.isinf, andrelax.isfiniteare registered in the op registry and emit valid IR, but lack FLegalize entries so LegalizeOps() leaves them unlowered and relax.build() crashes at codegen with:Same crash on
isinfandisfinite, on both LLVM and CUDA targets.The TOPI implementations already exist (python/tvm/topi/math.py). The fix is three register_legalize calls following the _call_topi_without_attr pattern used by the other unary ops in the same file.
Fixes #19452.