Skip to content

Commit

Permalink
Fixed automatic codegen issues with grad attr_map (#39358)
Browse files Browse the repository at this point in the history
  • Loading branch information
jim19930609 committed Feb 8, 2022
1 parent 5c3873f commit 6580522
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion paddle/fluid/eager/auto_code_generator/eager_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ static bool IgnoreGradAttribute(const std::string& op_type,
}
}

// Only allow SumOp
if (op_type != "sum") {
return true;
}

return false;
}

Expand Down Expand Up @@ -1693,7 +1698,7 @@ static std::string GenerateSingleOpBase(
VLOG(6) << "Generated Outs Map";

// [Generation] Get Attrs Map
const char* ATTRS_TEMPLATE = " auto %s = this->attr_map_;\n";
const char* ATTRS_TEMPLATE = " auto& %s = this->attr_map_;\n";
std::string grad_attrs_str =
paddle::string::Sprintf(ATTRS_TEMPLATE, attrs_name);
for (const auto& iter : grad_attrs) {
Expand Down

0 comments on commit 6580522

Please sign in to comment.