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

[Tensor Operants & Prim] Tensor pow API uses elementwise_pow #50886

Merged
merged 2 commits into from
Feb 27, 2023

Conversation

jiahy0825
Copy link
Contributor

PR types

Others

PR changes

Others

Describe

Tensor 重载 pow 时,使用 full + elementwise_pow 的组合方式进行调用。
目的:组合算子需求,尽量拆分为基础算子,相当于节省了 pow(const Tensor& x, const Scalar& y = 1.0f) 这个算子,统一使用 elementwise_pow

When attaching pow to Tensor, uses full + elementwise_pow to compose pow
Motivation: Requirements from prim, divide pow into fundamental operator can save the operator of pow(const Tensor& x, const Scalar& y = 1.0f).

@paddle-bot
Copy link

paddle-bot bot commented Feb 24, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -29,6 +29,8 @@

indent = " "

specific_ops_map = {"elementwise_pow": "pow"}
Copy link
Contributor

Choose a reason for hiding this comment

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

可以加点注释,说明一下作用

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Next PR fix this.

}

Tensor EagerTensorOperants::pow(const Tensor& x, const Scalar& y) {
return ::elementwise_pow_ad_func(x, ::full_like_ad_func(x, y));
Copy link
Contributor

Choose a reason for hiding this comment

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

这个为什么不使用pow的接口?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

此处来自组合算子需求,要求尽可能使用基础算子,使用 elementwise + full_like 做组合,可以节省一个 pow 算子(接口)

Prim requires to use basic operators as much as possible. Using elementwise + full_like can save the operator of pow.

@jiahy0825 jiahy0825 merged commit 8a09739 into PaddlePaddle:develop Feb 27, 2023
jiahy0825 added a commit to jiahy0825/Paddle that referenced this pull request Feb 27, 2023
jiahy0825 added a commit that referenced this pull request Mar 1, 2023
…50983)

* Add comments for #50886

* [Tensor Operants & Prim-Relevant] Tensor supports logical operants

* add prim dynamic unit test

* add prim static unit test
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.

4 participants