Add AnonymousIteratorHandleOp for non-shared Iterator resources
authorAllen Lavoie <allenl@google.com>
Tue, 29 May 2018 17:34:20 +0000 (10:34 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Tue, 29 May 2018 17:36:51 +0000 (10:36 -0700)
commit70674b950ab48f913ed1c99e48c4162287595d46
tree41d31d821db3daee9c30fa23d66237888657baa0
parent0acb6b7435f25e798acd59f24e590eeebef7df9a
Add AnonymousIteratorHandleOp for non-shared Iterator resources

Fixes Iterator cleanup when executing eagerly. DestroyResourceOp will now remove the last reference from the Iterator resource when it runs (after the last Python reference to an EagerIterator is removed).

Previously EagerIterator used IteratorHandleOp to create resource handles, which used one kernel per (unique) shared name since the shared name was an attribute. These kernels each held a reference to their resource, which kept it alive indefinitely.

Fixes #19499.

PiperOrigin-RevId: 198417997
tensorflow/core/api_def/base_api/api_def_AnonymousIterator.pbtxt [new file with mode: 0644]
tensorflow/core/api_def/python_api/api_def_AnonymousIterator.pbtxt [new file with mode: 0644]
tensorflow/core/kernels/data/iterator_ops.cc
tensorflow/core/ops/dataset_ops.cc
tensorflow/python/data/kernel_tests/reader_dataset_ops_test.py
tensorflow/python/data/ops/iterator_ops.py