-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Simplify building process of gradient operators #3192
Simplify building process of gradient operators #3192
Conversation
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!
@@ -161,8 +161,8 @@ TEST(Backward, simple_op_grad) { | |||
auto fwd = f::OpRegistry::CreateOp("rowwise_add", {"X", "b"}, {"Out"}, {}); | |||
ASSERT_NE(fwd, nullptr); | |||
auto gop = f::OpRegistry::CreateGradOp(*fwd); | |||
ASSERT_EQ(1UL, gop->inputs_.size()); | |||
ASSERT_EQ("Out" + f::OperatorBase::GRAD_VAR_SUFFIX(), gop->inputs_[0]); | |||
ASSERT_EQ(4UL, gop->inputs_.size()); |
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.
"I, O , OG" seems we really need 4UL, but why it pass the test smoothly?
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.
I changed it in this PR, it was 1UL and now is 4UL.
paddle/framework/grad_op_builder.cc
Outdated
int end_idx = format.empty() ? idx + 1 : format.at(idx + 1); | ||
return new OpInOutArg(var.name(), type, !var.ignore_gradient(), begin_idx, | ||
end_idx); | ||
enum OpArgType { IN, OUT }; |
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.
maybe enum class
is better.
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.
good idea!
fixes #3151