[BUG] Conversion compile issue#150
Merged
yaoyaoding merged 6 commits intohidet-org:mainfrom Apr 3, 2023
Merged
Conversation
yaoyaoding
reviewed
Mar 30, 2023
python/hidet/backend/codegen.py
Outdated
| return '(int64_t)(__half2ll_rz(' + self(e.expr) + '))' | ||
| elif dst_dtype == dtypes.uint64: | ||
| return '(uint64_t)(' + self(e.expr) + ')' | ||
| return '(uint64_t)(__half2ull_rz(' + self(e.expr) + '))' |
Member
There was a problem hiding this comment.
Hi Xin, what if the type of e.expr is not half?
Contributor
Author
There was a problem hiding this comment.
I think the type of e.expr is guarded by the if statement above
if isinstance(src_dtype, DataType) and isinstance(dst_dtype, DataType) and src_dtype == dtypes.float16:
Member
There was a problem hiding this comment.
Make sense. I did not notice the guarding if statement.
I am wondering if (int64_t)(long long)(expr) works or not?
Contributor
Author
There was a problem hiding this comment.
It does, and thanks for pointing it out, that would be a better idea because it is more generic, I made the change
…dd a few more test for completeness
yaoyaoding
approved these changes
Apr 2, 2023
Member
yaoyaoding
left a comment
There was a problem hiding this comment.
Thanks @xinli-git, looks good to me!
Contributor
Author
|
Hi @yaoyaoding all looks good now, could you take a final look ? |
Member
|
Thanks @xinli-git! |
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.
Hidet generated kernels contains cast operations such as:
will not compile due to the following error, as there is no explicit conversion defined from half to uint64_t
The proper conversion is defined here:
After some testing, only int64 and short cannot be directly casted, but would require additional handling, as seen in PR