Skip to content
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

[part 5]change type of function args #38889

Merged
merged 1 commit into from
Jan 17, 2022

Conversation

zhangting2020
Copy link
Contributor

PR types

Function optimization

PR changes

OPs

Describe

[part 5]change type of function args

#38859 支持不同输入类型的elementwise op,需要修改计算函数的参数为值传递

@paddle-bot-old
Copy link

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

return std::llrint(
std::pow(static_cast<double>(args[0]), static_cast<double>(args[1])));
std::pow(static_cast<double>(a), static_cast<double>(b)));
Copy link
Contributor

Choose a reason for hiding this comment

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

mod和pow也可以用.h里面的functor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

T res = fmod(a, b);
if ((res != 0) && ((b < 0) != (res < 0))) res += b;
T res = b % a;
if ((res != 0) && ((res < 0) != (a < 0))) res += a;
return res;
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

下面还有个InverseModFunctorFP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

InverseModFunctorFP是CPU下,x_dims.size() < y_dims.size()时用到的,暂时没有改动这个接口。只是原来的实现Mod和InverseMode的位置问题,导致diff显示修改了InverseModFunctor


// Accoding to #PR26732: in dividen % divsor
// remainder shall have the same sign as divsor.
if ((res != 0) && ((b ^ res) < 0)) res += b;
Copy link
Contributor

Choose a reason for hiding this comment

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

check下判断条件

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里没问题,Mod用的b,InverseMod用的a

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. 建议把InverseModFunctorFP也改了,不然这个代码看着挺迷惑的

@zhangting2020 zhangting2020 merged commit ac93323 into PaddlePaddle:develop Jan 17, 2022
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