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

Calculating gradients for partial graph #7269

Merged
merged 3 commits into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion paddle/framework/grad_op_desc_maker.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ class GradOpDescMakerBase {
auto onames = this->Output(name);
ret_val.reserve(onames.size());
std::transform(onames.begin(), onames.end(), std::back_inserter(ret_val),
GradVarName);
[this](const std::string& fwd_var_name) -> std::string {
auto g_name = GradVarName(fwd_var_name);
(*this->grad_to_var_)[g_name] = fwd_var_name;
return g_name;
});
return ret_val;
}

Expand Down
2 changes: 1 addition & 1 deletion paddle/framework/op_desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class OpDesc {
}

proto::OpDesc desc_;
// input arg name => output variable names
// input arg name => input variable names
VariableNameMap inputs_;
// output arg name => output variable names
VariableNameMap outputs_;
Expand Down
2 changes: 1 addition & 1 deletion paddle/operators/norm_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class NormOpMaker : public framework::OpProtoAndCheckerMaker {
"M = C * H * W");
AddComment(R"DOC(
"Input shape: $(N, C, H, W)$
Sclae shape: $(C, 1)$
Scale shape: $(C, 1)$
Output shape: $(N, C, H, W)$
Where
forward
Expand Down
2 changes: 1 addition & 1 deletion paddle/operators/norm_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class NormKernel : public framework::OpKernel<T> {
context.GetPlace());
auto tmp = framework::EigenVector<T, Eigen::RowMajor,
Eigen::DenseIndex>::Flatten(tmp_tensor);
// get colsum and sqrt , inverse
// get colsum and sqrt , inverse
auto dim = Eigen::array<int, 1>({{0}});
tmp.device(*place) = x_square_batch_eigen.sum(dim);
tmp.device(*place) = (tmp + epsilon).sqrt().inverse();
Expand Down
Loading