MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / IteratorResourceDeleter

Class IteratorResourceDeleter

tensorflow/python/data/ops/iterator_ops.py:530–553  ·  view source on GitHub ↗

An object which cleans up an iterator resource handle. An alternative to defining a __del__ method on an object. Even if the parent object is part of a reference cycle, the cycle will be collectable.

Source from the content-addressed store, hash-verified

528
529
530class IteratorResourceDeleter(object):
531 """An object which cleans up an iterator resource handle.
532
533 An alternative to defining a __del__ method on an object. Even if the parent
534 object is part of a reference cycle, the cycle will be collectable.
535 """
536
537 def __init__(self, handle, device, deleter):
538 self._deleter = deleter
539 self._handle = handle
540 self._device = device
541 self._eager_mode = context.executing_eagerly()
542
543 def __del__(self):
544 with ops.device(self._device):
545 # Make sure the resource is deleted in the same mode as it was created in.
546 if self._eager_mode:
547 with context.eager_mode():
548 gen_dataset_ops.delete_iterator(
549 handle=self._handle, deleter=self._deleter)
550 else:
551 with context.graph_mode():
552 gen_dataset_ops.delete_iterator(
553 handle=self._handle, deleter=self._deleter)
554
555
556class IteratorV2(trackable.Trackable, composite_tensor.CompositeTensor):

Callers 2

__init__Method · 0.85
_create_iteratorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected