-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
79844a5
to
fb82552
Compare
fb82552
to
36ae90a
Compare
There was a problem hiding this 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"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以加点注释,说明一下作用
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个为什么不使用pow的接口?
There was a problem hiding this comment.
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
.
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, usesfull + elementwise_pow
to composepow
Motivation: Requirements from prim, divide pow into fundamental operator can save the operator of
pow(const Tensor& x, const Scalar& y = 1.0f)
.