Make grad name unique (#4788)

* Make grad name unique

* Modify for review comment
This commit is contained in:
ashbhandare 2020-08-14 15:17:17 -07:00 committed by GitHub
parent afa89566d7
commit 5a8962d327
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -37,7 +37,7 @@ typedef std::vector<NodeDef> GradientDef;
class GradientBuilderBase {
public:
GradientBuilderBase(const GradientGraphConfiguration& gradient_graph_config,
const Graph* graph,
Graph* graph,
const Node* node,
const std::unordered_set<std::string>& gradient_inputs,
const std::unordered_set<std::string>& gradient_outputs,
@ -217,13 +217,13 @@ class GradientBuilderBase {
if (!name.empty()) {
unique_prefix << name << "_Grad/";
} else {
unique_prefix << node_->OpType() << "_" << node_->Index() << "_Grad/";
unique_prefix << graph_->GenerateNodeName(node_->OpType()) << "_Grad/";
}
return unique_prefix.str();
}
const GradientGraphConfiguration& gradient_graph_config_;
const Graph* graph_;
Graph* graph_;
const Node* node_;
std::string unique_node_prefix_;

View file

@ -9,7 +9,7 @@ namespace onnxruntime {
namespace training {
GradientDef GetGradientForOp(const GradientGraphConfiguration& gradient_graph_config,
const Graph* graph,
Graph* graph,
const Node* node,
const std::unordered_set<std::string>& output_args_need_grad,
const std::unordered_set<std::string>& input_args_need_grad,

View file

@ -13,7 +13,7 @@ namespace training {
typedef GenericRegistry<GradientBuilderBase,
const GradientGraphConfiguration&,
const Graph*&, // graph
Graph*&, // graph
const Node*&, // node
const std::unordered_set<std::string>&, // gradient_inputs
const std::unordered_set<std::string>&, // gradient_outputs
@ -35,7 +35,7 @@ class GradientBuilderRegistry : public GradientRegistryType {
};
GradientDef GetGradientForOp(const GradientGraphConfiguration& gradient_graph_config,
const Graph* graph,
Graph* graph,
const Node* node,
const std::unordered_set<std::string>& output_args_need_grad,
const std::unordered_set<std::string>& input_args_need_grad,