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 #ifndef TENSORFLOW_LITE_TOCO_TFLITE_IMPORT_H_ 16 #define TENSORFLOW_LITE_TOCO_TFLITE_IMPORT_H_ 17 18 #include <string> 19 20 #include "tensorflow/lite/schema/schema_generated.h" 21 #include "tensorflow/lite/toco/model.h" 22 23 namespace toco { 24 25 namespace tflite { 26 27 // Parse the given string as TF Lite flatbuffer and return a new tf.mini model. 28 std::unique_ptr<Model> Import(const ModelFlags &model_flags, 29 const std::string &input_file_contents); 30 31 namespace details { 32 33 // The names of all tensors found in a TF Lite model. 34 using TensorsTable = std::vector<std::string>; 35 36 // The names of all operators found in TF Lite model. If the operator is 37 // builtin, the string representation of the corresponding enum value is used 38 // as name. 39 using OperatorsTable = std::vector<std::string>; 40 41 void LoadTensorsTable(const ::tflite::Model &input_model, 42 TensorsTable *tensors_table); 43 void LoadOperatorsTable(const ::tflite::Model &input_model, 44 OperatorsTable *operators_table); 45 46 } // namespace details 47 } // namespace tflite 48 49 } // namespace toco 50 51 #endif // TENSORFLOW_LITE_TOCO_TFLITE_IMPORT_H_ 52