Пример #1
0
 def _register_dead_handle(self, handle):
   # Register a dead handle in the session. Delete the dead tensors when
   # the number of dead tensors exceeds certain threshold.
   tensors_to_delete = None
   with self._delete_lock:
     self._dead_handles.append(handle)
     if len(self._dead_handles) == BaseSession._DEAD_HANDLES_THRESHOLD:
       tensors_to_delete = self._dead_handles
       self._dead_handles = []
   # Delete the dead tensors.
   # TODO(yuanbyu): For now we use a sequence of runs to minimize the graph
   # size and the overhead of graph construction/partitioning.
   if tensors_to_delete:
     for tensor_handle in tensors_to_delete:
       feeds = {}
       fetches = []
       holder, deleter = session_ops._get_handle_deleter(self.graph,
                                                         tensor_handle)
       feeds[holder] = tensor_handle
       fetches.append(deleter)
       self.run(fetches, feed_dict=feeds)
Пример #2
0
 def _register_dead_handle(self, handle):
   # Register a dead handle in the session. Delete the dead tensors when
   # the number of dead tensors exceeds certain threshold.
   tensors_to_delete = None
   with self._delete_lock:
     self._dead_handles.append(handle)
     if len(self._dead_handles) == BaseSession._DEAD_HANDLES_THRESHOLD:
       tensors_to_delete = self._dead_handles
       self._dead_handles = []
   # Delete the dead tensors.
   # TODO(yuanbyu): For now we use a sequence of runs to minimize the graph
   # size and the overhead of graph construction/partitioning.
   if tensors_to_delete:
     for tensor_handle in tensors_to_delete:
       feeds = {}
       fetches = []
       holder, deleter = session_ops._get_handle_deleter(self.graph,
                                                         tensor_handle)
       feeds[holder] = tensor_handle
       fetches.append(deleter)
       self.run(fetches, feed_dict=feeds)