1# Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================== 15"""Python wrapper for prefetching_ops.""" 16from __future__ import absolute_import 17from __future__ import division 18from __future__ import print_function 19 20from tensorflow.contrib.data.python.ops import contrib_op_loader # pylint: disable=unused-import 21from tensorflow.contrib.data.python.ops import gen_dataset_ops 22 23 24# TODO(rohanj): Add a python class that constructs resource in the __init__ 25# method and provides a get_next() that calls the prefetch op. 26def function_buffering_resource(string_arg, 27 target_device, 28 shared_name, 29 f, 30 buffer_size, 31 thread_pool_size=1, 32 container="", 33 name=None): 34 return gen_dataset_ops.function_buffering_resource( 35 string_arg=string_arg, 36 target_device=target_device, 37 shared_name=shared_name, 38 f=f, 39 buffer_size=buffer_size, 40 thread_pool_size=thread_pool_size, 41 container=container, 42 name=name) 43 44 45def function_buffering_resource_get_next(function_buffer_resource, 46 output_types, 47 name=None): 48 return gen_dataset_ops.function_buffering_resource_get_next( 49 function_buffer_resource=function_buffer_resource, 50 output_types=output_types, 51 name=name) 52