Remove tracking of inbound nodes/outbound nodes.

When building a Sequential model, clear_previously_created_nodes accidentally added tracking to the nodes attributes, which causes unnecessary warnings when loading a checkpoint.

PiperOrigin-RevId: 324923805
Change-Id: I7ee4457b70b16bb1a3b410f41327bba269a128e5
This commit is contained in:
Katherine Wu 2020-08-04 17:20:06 -07:00 committed by TensorFlower Gardener
parent 84d053187c
commit 3f45c33ba5
2 changed files with 40 additions and 4 deletions

View File

@ -382,8 +382,8 @@ class Layer(module.Module, version_utils.LayerVersionSelector):
# These lists will be filled via successive calls
# to self._add_inbound_node().
# Used in symbolic mode only, only in conjunction with graph-networks
self._inbound_nodes = []
self._outbound_nodes = []
self._inbound_nodes_value = []
self._outbound_nodes_value = []
self._init_call_fn_args()
@ -2268,6 +2268,24 @@ class Layer(module.Module, version_utils.LayerVersionSelector):
# Methods & attributes below are all private and only used by the framework. #
##############################################################################
@property
def _inbound_nodes(self):
return self._inbound_nodes_value
@_inbound_nodes.setter
@trackable.no_automatic_dependency_tracking
def _inbound_nodes(self, value):
self._inbound_nodes_value = value
@property
def _outbound_nodes(self):
return self._outbound_nodes_value
@_outbound_nodes.setter
@trackable.no_automatic_dependency_tracking
def _outbound_nodes(self, value):
self._outbound_nodes_value = value
def _set_dtype_policy(self, dtype):
"""Sets self._dtype_policy."""
if isinstance(dtype, policy.Policy):

View File

@ -217,8 +217,8 @@ class Layer(base_layer.Layer):
# These lists will be filled via successive calls
# to self._add_inbound_node().
# Used in symbolic mode only, only in conjunction with graph-networks
self._inbound_nodes = []
self._outbound_nodes = []
self._inbound_nodes_value = []
self._outbound_nodes_value = []
self._init_call_fn_args()
@ -1740,6 +1740,24 @@ class Layer(base_layer.Layer):
# Methods & attributes below are all private and only used by the framework. #
##############################################################################
@property
def _inbound_nodes(self):
return self._inbound_nodes_value
@_inbound_nodes.setter
@trackable.no_automatic_dependency_tracking
def _inbound_nodes(self, value):
self._inbound_nodes_value = value
@property
def _outbound_nodes(self):
return self._outbound_nodes_value
@_outbound_nodes.setter
@trackable.no_automatic_dependency_tracking
def _outbound_nodes(self, value):
self._outbound_nodes_value = value
def _set_dtype_policy(self, dtype):
"""Sets self._dtype_policy."""
if isinstance(dtype, policy.Policy):