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 16 // The file input provides a mechanism to feed grappler with existing TensorFlow 17 // graphs stored in TensorFlow checkpoints. Note that at this point the weights 18 // that may be stored in the checkpoint are not restored in order to speedup the 19 // initialization. 20 21 #ifndef TENSORFLOW_CORE_GRAPPLER_INPUTS_FILE_INPUT_YIELDER_H_ 22 #define TENSORFLOW_CORE_GRAPPLER_INPUTS_FILE_INPUT_YIELDER_H_ 23 24 #include <stddef.h> 25 #include <limits> 26 #include <vector> 27 #include "tensorflow/core/grappler/inputs/input_yielder.h" 28 #include "tensorflow/core/platform/types.h" 29 30 namespace tensorflow { 31 namespace grappler { 32 33 class GrapplerItem; 34 35 class FileInputYielder : public InputYielder { 36 public: 37 // Iterates over the files specified in the list of 'filename' up to 38 // 'max_iterations' times. 39 explicit FileInputYielder( 40 const std::vector<string>& filenames, 41 size_t max_iterations = std::numeric_limits<size_t>::max()); 42 bool NextItem(GrapplerItem* item) override; 43 44 private: 45 const std::vector<string> filenames_; 46 size_t current_file_; 47 size_t current_iteration_; 48 size_t max_iterations_; 49 50 size_t bad_inputs_; 51 }; 52 53 } // end namespace grappler 54 } // end namespace tensorflow 55 56 #endif // TENSORFLOW_CORE_GRAPPLER_INPUTS_FILE_INPUT_YIELDER_H_ 57