diff options
Diffstat (limited to 'tensorflow/python/framework/ops.py')
-rw-r--r-- | tensorflow/python/framework/ops.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/tensorflow/python/framework/ops.py b/tensorflow/python/framework/ops.py index 89afd1d25b..cf0b1e36fb 100644 --- a/tensorflow/python/framework/ops.py +++ b/tensorflow/python/framework/ops.py @@ -3239,8 +3239,9 @@ class Graph(object): # the name will still appear in _names_in_use even though the name hasn't # been used. This is ok, just leave _names_in_use as-is in this case. # TODO(skyewm): make the C API guarantee no name conflicts. - if ret.name not in self._names_in_use: - self._names_in_use[ret.name] = 1 + name_key = ret.name.lower() + if name_key not in self._names_in_use: + self._names_in_use[name_key] = 1 self._create_op_helper(ret, compute_device=compute_device) return ret @@ -3949,20 +3950,27 @@ class Graph(object): """ if self._name_stack: name = self._name_stack + "/" + name - i = self._names_in_use.get(name, 0) - # Increment the number for "name". + + # For the sake of checking for names in use, we treat names as case + # insensitive (e.g. foo = Foo). + name_key = name.lower() + i = self._names_in_use.get(name_key, 0) + # Increment the number for "name_key". if mark_as_used: - self._names_in_use[name] = i + 1 + self._names_in_use[name_key] = i + 1 if i > 0: - base_name = name - # Make sure the composed name is not already used. - while name in self._names_in_use: - name = "%s_%d" % (base_name, i) + base_name_key = name_key + # Make sure the composed name key is not already used. + while name_key in self._names_in_use: + name_key = "%s_%d" % (base_name_key, i) i += 1 - # Mark the composed name as used in case someone wants + # Mark the composed name_key as used in case someone wants # to call unique_name("name_1"). if mark_as_used: - self._names_in_use[name] = 1 + self._names_in_use[name_key] = 1 + + # Return the new name with the original capitalization of the given name. + name = "%s_%d" % (name, i-1) return name def get_name_scope(self): |