Skip to content

Conversation

@ZzSean
Copy link
Contributor

@ZzSean ZzSean commented May 10, 2021

PR types

Performance optimization

PR changes

OPs

Describe

elementwise 实现模版支持输入和输出的数据类型不同,并适配 abs 验证,性能数据如下:

config dt paddle old paddle new pro pytorch pro
[16, 128, 257, 257] fp16 852.23us 668.53us 27.48% 750.56us 12.27%
[16, 128, 257, 257] fp32 1.3771ms 1.3109ms 5.05% 1.3115ms 0.05%
优化后,性能已经打平甚至优于 pytorch

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@Xreki Xreki left a comment

Choose a reason for hiding this comment

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

LGTM and great work~

}

template <ElementwiseType ET, typename T, typename Functor>
template <ElementwiseType ET, typename InT, typename OutT, typename Functor>
Copy link
Contributor

Choose a reason for hiding this comment

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

可以设置默认值OutT = InT吗?

for (auto iter = ins.begin(); iter != ins.end(); ++iter) {
vec_size =
std::min<int>(vec_size, GetVectorizedSizeImpl((*iter)->data<T>()));
std::min<int>(vec_size, GetVectorizedSizeImpl((*iter)->data<InT>()));
Copy link
Contributor

Choose a reason for hiding this comment

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

这个循环的写法其实可以简写成如下:

for (auto in : ins) {
  vec_size =
        std::min<int>(vec_size, GetVectorizedSizeImpl(in->data<InT>()));
}

@Xreki Xreki merged commit 3419de5 into PaddlePaddle:develop May 10, 2021
@ZzSean ZzSean deleted the support_two_dt branch May 18, 2021 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants