Support comparision binarary ops#33064
Merged
Xreki merged 22 commits intoPaddlePaddle:developfrom Jun 2, 2021
Merged
Conversation
|
Thanks for your contribution! |
6379fff to
259ecb2
Compare
Contributor
|
验证一下#33086 里面的这个case。 |
Contributor
Author
Contributor
|
辛苦代码合入后也把相应的代码合入到2.1分支上,#33086 该PR的改动将不会cherry-pick分支 |
Contributor
Xreki
approved these changes
Jun 2, 2021
Contributor
Xreki
left a comment
There was a problem hiding this comment.
LGTM both for the modification of the PR and op benchmark ci.
- op benchmark ci跳过了controlflow目录中的源码的修改,所以ci没有测试到比较类op。本pr没有修改elementwise_xxx计算的代码,所以op benchmark ci上的性能问题纯属波动。
- 2个review建议,下个PR一起看下。
| * To pack the input and output tnesors into vector for | ||
| * LaunchElementwiseCudaKernel | ||
| */ | ||
| template <typename T> |
| ops::CompareOpKernel<plat::CUDADeviceContext, \ | ||
| ops::func##Functor<double>, void>); | ||
|
|
||
| REGISTER_CUDA_COMPARE_KERNEL(equal, CudaEqual) |
Contributor
There was a problem hiding this comment.
虽然是为了减少公共代码,但是Functor后缀还是不要放到宏里面的好,宏参数还是最好传一个完整的函数:REGISTER_CUDA_COMPARE_KERNEL(equal, CudaEqualFunctor),直观便于理解。
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.
PR types
Performance optimization
PR changes
OPs
Describe
Supporting cuda binary comparision OPs whose return type is boolean, namely:
equal
not euqal
large_than
less_than
large_equal
less_equal
The performance variation is below:

As can be seen in the table, the time cost of most of test cases reflect the great improvment in logical ops after optimization of Elementwise and Broadcast op, while the develop branch takes the adavantage of thrust::cuda_cub::core:: dealing with the first test case.