-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OpenCL] Fix type casting error #11021
Merged
Merged
Conversation
This file contains 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
echuraev
force-pushed
the
echuraev/fix_opencl_type_casting
branch
from
April 15, 2022 09:50
e448d31
to
c73f181
Compare
Faced situation when generated OpenCL kernel contained the following if condition: ``` if (uint4(...) && (int4(...) == int4(...))) ``` In this case, got the following error: "can't convert between vector values of different size ('uint4' and 'int __attribute__((ext_vector_type(4)))')" Added casts for binary ops. But it was necessary to modify `CastFromTo` and add new method `CastTo`. Because with `CastFromTo` the following code was generated: ``` if (uint4(...) && (convert_uint4(int4(...)) == convert_uint4(int4(...)))) ``` But the OpenCL compiler still generated the same error. This is why added new method `CastTo`. In this method we don't check the current type of op and just add cast to a new type. Finally the following code will be generated: ``` if (uint4(...) && convert_uint4(convert_uint4(int4(...)) == convert_uint4(int4(...)))) ```
echuraev
force-pushed
the
echuraev/fix_opencl_type_casting
branch
from
April 15, 2022 09:59
c73f181
to
e2cb3e3
Compare
Sorry, closed and opened this PR several times, due to on our branch I saw some problems with generated kernels. But all these problems were specific for our branch, because we have modified the codegen. This PR should work on the tvm/main. @csullivan, @masahi, @comaniac please, review it. |
masahi
approved these changes
Apr 15, 2022
echuraev
added a commit
to echuraev/tvm
that referenced
this pull request
Apr 18, 2022
This reverts commit 8aafe5b.
echuraev
added a commit
to echuraev/tvm
that referenced
this pull request
Apr 18, 2022
The previous PR apache#11021 was reverted in apache#11035 due to it affected performance of generated OpenCL code. This PR fixed the same issue but doesn't lead to performance degradation. Tested on Resnet50_v2 network.
echuraev
added a commit
to echuraev/tvm
that referenced
this pull request
Apr 19, 2022
This reverts commit 8aafe5b.
Lucien0
pushed a commit
to Lucien0/tvm
that referenced
this pull request
Apr 19, 2022
Faced situation when generated OpenCL kernel contained the following if condition: ``` if (uint4(...) && (int4(...) == int4(...))) ``` In this case, got the following error: "can't convert between vector values of different size ('uint4' and 'int __attribute__((ext_vector_type(4)))')" Added casts for binary ops. But it was necessary to modify `CastFromTo` and add new method `CastTo`. Because with `CastFromTo` the following code was generated: ``` if (uint4(...) && (convert_uint4(int4(...)) == convert_uint4(int4(...)))) ``` But the OpenCL compiler still generated the same error. This is why added new method `CastTo`. In this method we don't check the current type of op and just add cast to a new type. Finally the following code will be generated: ``` if (uint4(...) && convert_uint4(convert_uint4(int4(...)) == convert_uint4(int4(...)))) ```
masahi
pushed a commit
that referenced
this pull request
Apr 19, 2022
echuraev
added a commit
to echuraev/tvm
that referenced
this pull request
Apr 19, 2022
The previous PR apache#11021 was reverted in apache#11035 due to it affected performance of generated OpenCL code. This PR fixed the same issue but doesn't lead to performance degradation. Tested on Resnet50_v2 network.
driazati
pushed a commit
to driazati/tvm
that referenced
this pull request
Apr 19, 2022
* [OpenCL] Fix type casting The previous PR apache#11021 was reverted in apache#11035 due to it affected performance of generated OpenCL code. This PR fixed the same issue but doesn't lead to performance degradation. Tested on Resnet50_v2 network. * Implement using select built-in
altanh
pushed a commit
to altanh/tvm
that referenced
this pull request
Apr 28, 2022
Faced situation when generated OpenCL kernel contained the following if condition: ``` if (uint4(...) && (int4(...) == int4(...))) ``` In this case, got the following error: "can't convert between vector values of different size ('uint4' and 'int __attribute__((ext_vector_type(4)))')" Added casts for binary ops. But it was necessary to modify `CastFromTo` and add new method `CastTo`. Because with `CastFromTo` the following code was generated: ``` if (uint4(...) && (convert_uint4(int4(...)) == convert_uint4(int4(...)))) ``` But the OpenCL compiler still generated the same error. This is why added new method `CastTo`. In this method we don't check the current type of op and just add cast to a new type. Finally the following code will be generated: ``` if (uint4(...) && convert_uint4(convert_uint4(int4(...)) == convert_uint4(int4(...)))) ```
altanh
pushed a commit
to altanh/tvm
that referenced
this pull request
Apr 28, 2022
This reverts commit 8aafe5b.
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.
Faced situation when generated OpenCL kernel contained the following if
condition:
In this case, got the following error:
"can't convert between vector values of different size ('uint4' and 'int attribute((ext_vector_type(4)))')"
Added casts for binary ops. But it was necessary to modify
CastFromTo
and add new method
CastTo
. Because withCastFromTo
the followingcode was generated:
But the OpenCL compiler still generated the same error.
This is why added new method
CastTo
. In this method we don't check thecurrent type of op and just add cast to a new type.
Finally the following code will be generated:
Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.