From 70674b950ab48f913ed1c99e48c4162287595d46 Mon Sep 17 00:00:00 2001 From: Allen Lavoie Date: Tue, 29 May 2018 10:34:20 -0700 Subject: [PATCH] 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 --- .../base_api/api_def_AnonymousIterator.pbtxt | 13 ++++ .../python_api/api_def_AnonymousIterator.pbtxt | 4 ++ tensorflow/core/kernels/data/iterator_ops.cc | 74 ++++++++++++++++++++++ tensorflow/core/ops/dataset_ops.cc | 6 ++ .../data/kernel_tests/reader_dataset_ops_test.py | 36 +++++++++++ tensorflow/python/data/ops/iterator_ops.py | 4 +- 6 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 tensorflow/core/api_def/base_api/api_def_AnonymousIterator.pbtxt create mode 100644 tensorflow/core/api_def/python_api/api_def_AnonymousIterator.pbtxt diff --git a/tensorflow/core/api_def/base_api/api_def_AnonymousIterator.pbtxt b/tensorflow/core/api_def/base_api/api_def_AnonymousIterator.pbtxt new file mode 100644 index 0000000..d8c2ed4 --- /dev/null +++ b/tensorflow/core/api_def/base_api/api_def_AnonymousIterator.pbtxt @@ -0,0 +1,13 @@ +op { + graph_op_name: "AnonymousIterator" + out_arg { + name: "handle" + description: <