-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Support comparision binarary ops #33064
Support comparision binarary ops #33064
Conversation
Thanks for your contribution! |
6379fff
to
259ecb2
Compare
验证一下#33086 里面的这个case。 |
辛苦代码合入后也把相应的代码合入到2.1分支上,#33086 该PR的改动将不会cherry-pick分支 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
模板里面最好标明是OutT
。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下个PR修改掉
ops::CompareOpKernel<plat::CUDADeviceContext, \ | ||
ops::func##Functor<double>, void>); | ||
|
||
REGISTER_CUDA_COMPARE_KERNEL(equal, CudaEqual) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
虽然是为了减少公共代码,但是Functor
后缀还是不要放到宏里面的好,宏参数还是最好传一个完整的函数:REGISTER_CUDA_COMPARE_KERNEL(equal, CudaEqualFunctor)
,直观便于理解。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下个PR中一并修改掉
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.