-
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
【prim】Elementwise double grad #53014
【prim】Elementwise double grad #53014
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
… elementwise_double_grad
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.
some comments
this->GetSingleInputGrad(framework::GradVarName("Out")); | ||
|
||
// get attr | ||
int axis = static_cast<int>(this->Attr<int>("axis")); |
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.
This is removed?
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.
no
|
||
// get attr | ||
int axis = static_cast<int>(this->Attr<int>("axis")); | ||
PADDLE_ENFORCE_EQ( |
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.
same
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.
no
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.
one comment
python/paddle/fluid/backward.py
Outdated
name | ||
for name in op_desc.input_arg_names() | ||
if is_grad_name(name) | ||
] | ||
if len(input_grad_names) == 0: |
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.
will this cause error?
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.
modify by cxxly
const Tensor& grad_out, | ||
const paddle::optional<Tensor>& grad_x_grad, | ||
const paddle::optional<Tensor>& grad_y_grad, | ||
int axis, |
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.
如果已经在maker处强制要求axis为-1,这里的axis参数是不就可以去掉了?
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.
函数签名需要和yaml 配置严格一致
const Tensor& grad_out, | ||
const paddle::optional<Tensor>& grad_x_grad, | ||
const paddle::optional<Tensor>& grad_y_grad, | ||
int axis, |
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.
同上
@@ -114,5 +114,23 @@ static std::vector<DST_T> unsafe_vector_cast(const std::vector<SRC_T>& src) { | |||
return dst; | |||
} | |||
|
|||
// This fucction compute unsqueeze dims for reshape to replace unsqueeze. | |||
static std::vector<int> get_unsqueeze_dims(const Tensor& origin, | |||
const IntArray& axis) { |
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.
这里用IntArray
是需要支持Tensor类型的参数吗?
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.
不需要,此函数代替unsqueeze算子,对齐unsqueeze 算子的输入类型
@@ -0,0 +1,334 @@ | |||
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. |
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.
2022 -> 2023
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 will modify
… elementwise_double_grad
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.
由于axis越界获取的值在ci机器上刚好判断进入axis[j] == int64_t((i))分支,导致出错且本地无法复现
PR types
Others
PR changes
Others
Description
Pcard-66975
拆解 elementwise系列算子二阶,使得科学计算模型不需要开启prim_flag即可完成无限阶高阶计算