Skip to content

Implement FunctionTraits to support two kinds of elementwise functor and remove some old codes for broadcast. #35688

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

Merged
merged 33 commits into from
Sep 14, 2021

Conversation

Xreki
Copy link
Contributor

@Xreki Xreki commented Sep 13, 2021

PR types

Function optimization

PR changes

OPs

Describe

重新实现#35487 ,解决编译错误(#35686)。

#35487 引入了一个FunctionTraits,对于重载了operator()的Functor,可以在编译时静态获取Functor的2个特征,并写入静态变量:(1)operator()的参数个数arity(2)operator()有且只有一个参数时,第一个参数是否是指针类型,用以在Elementwise实现中,支持如下形式的Functor,以支持任意元计算

template <typename T>
struct CudaAddFunctor {
  inline HOSTDEVICE T operator()(T args[]) const { return args[0] + args[1]; }
};

#35487 中定义的FunctionTraits要求operator()必须定义成const,#35635 中使用了非const的Functor,所以发生了编译错误。本PR主要工作是:加强FunctionTraits,支持非const的operator()

Xreki added 30 commits September 2, 2021 05:51
@paddle-bot-old
Copy link

paddle-bot-old bot commented Sep 13, 2021

✅ This PR's description meets the template requirements!
Please wait for other CI results.

@paddle-bot-old
Copy link

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

@Xreki Xreki changed the title Opt/elementwise clear 2 Implement FunctionTraits to support two kinds of elementwise functor and remove some old codes for broadcast. Sep 13, 2021
@Xreki Xreki requested a review from zhangting2020 September 14, 2021 09:41
@Xreki Xreki merged commit 12bf050 into PaddlePaddle:develop Sep 14, 2021
@Xreki Xreki deleted the opt/elementwise_clear_2 branch September 14, 2021 12:17
AnnaTrainingG pushed a commit to AnnaTrainingG/Paddle that referenced this pull request Sep 29, 2021
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.

3 participants