-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Modified sigmoid by the elementwise interface. #39898
Modified sigmoid by the elementwise interface. #39898
Conversation
template <typename T> | ||
struct DivFunctor { | ||
const T *norm_; | ||
HOSTDEVICE inline DivFunctor(const T *norm) : norm_(norm) {} |
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.
这里也可以直接使用double存储div = 1/norm 然后在下面使用loss = loss * div
const std::vector<int> reduce_dim = {1}; | ||
TensorReduceImpl<T, T, kps::AddFunctor, NonzeroFunctor<T>>( | ||
context.cuda_device_context(), *counts_tensor, norm_tensor, | ||
NonzeroFunctor<T>(), reduce_dim, dev_ctx.stream()); |
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.
1.这里为什么使用NonzeroFunctor ? NonzeroFunctor有类型转换, 使用identityFunctor比较合适
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
PR types
Performance optimization
PR changes
OPs
Describe
Use elementwise interface to optimize sigmoid