Skip to content

Conversation

@huangxu96
Copy link
Contributor

PR types

Performance optimization

PR changes

OPs

Describe

Use elementwise interface to optimize sigmoid

@huangxu96 huangxu96 changed the title Modified sigmoid by elementwise interface. Modified sigmoid by the elementwise interface. Mar 2, 2022
template <typename T>
struct DivFunctor {
const T *norm_;
HOSTDEVICE inline DivFunctor(const T *norm) : norm_(norm) {}
Copy link
Contributor

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());
Copy link
Contributor

@AnnaTrainingG AnnaTrainingG Mar 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.这里为什么使用NonzeroFunctor ? NonzeroFunctor有类型转换, 使用identityFunctor比较合适

Copy link
Contributor

@AnnaTrainingG AnnaTrainingG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xingfeng01 xingfeng01 merged commit 5d9e11a into PaddlePaddle:develop Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants