You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by la...@apache.org on 2020/11/10 19:42:07 UTC

[incubator-mxnet] branch master updated: Unique names for nodes in imperative mode (#19509)

This is an automated email from the ASF dual-hosted git repository.

lausen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 74e5392  Unique names for nodes in imperative mode (#19509)
74e5392 is described below

commit 74e5392253079b42a3b76d0aa1ba8ce3ef5a35a7
Author: bgawrych <ba...@intel.com>
AuthorDate: Tue Nov 10 20:41:10 2020 +0100

    Unique names for nodes in imperative mode (#19509)
    
    Fix a regression in https://github.com/apache/incubator-mxnet/commit/5b7a6d979b3bcf43416be25a6e47e0fd150daa54 affecting the graphs recorded via HybridBlock.forward
---
 src/imperative/imperative.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/imperative/imperative.cc b/src/imperative/imperative.cc
index 073cfa4..d073858 100644
--- a/src/imperative/imperative.cc
+++ b/src/imperative/imperative.cc
@@ -233,7 +233,8 @@ void Imperative::RecordOp(
 
   nnvm::ObjectPtr node = nnvm::Node::Create();
   node->attrs = std::move(attrs);
-  if (node->attrs.name == "") {
+  // if node name is empty or node name is equal to op name - name it with unique name
+  if (node->attrs.name == "" || node->attrs.op->name == node->attrs.name) {
     node->attrs.name = "node_" + std::to_string(node_count_++);
   } else {
     node_count_++;
@@ -326,7 +327,8 @@ void Imperative::RecordDeferredCompute(nnvm::NodeAttrs &&attrs,
   }
   node->attrs = std::move(attrs);
   // Need to support NameManager in imperative API to better name node->attrs.name
-  if (node->attrs.name == "") {
+  // if node name is empty or node name is equal to op name - name it with unique name
+  if (node->attrs.name == "" || node->attrs.op->name == node->attrs.name) {
     node->attrs.name = "node_" + std::to_string(node_count_++);
   } else {
     node_count_++;