1 /* Copyright 2019 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 #ifndef TENSORFLOW_TENSORFLOW_LITE_SUPPORT_CODEGEN_METADATA_HELPER_H_ 17 #define TENSORFLOW_TENSORFLOW_LITE_SUPPORT_CODEGEN_METADATA_HELPER_H_ 18 19 #include <string> 20 21 #include "tensorflow_lite_support/codegen/utils.h" 22 #include "tensorflow_lite_support/metadata/metadata_schema_generated.h" 23 #include "tensorflow/lite/schema/schema_generated.h" 24 25 namespace tflite { 26 namespace support { 27 namespace codegen { 28 29 /// Parses a ModelMetadata out from a Model. The returned ModelMetadata's 30 /// lifetime is scoped by the model. 31 /// Returns nullptr if we cannot find any metadata. 32 const ModelMetadata* GetMetadataFromModel(const Model* model); 33 34 /// Finds an associated file from a TensorMetadata of certain type. If there're 35 /// multiple files meet the criteria, only the first one is used. If there's no 36 /// file meets the criteria, -1 will be returned. 37 int FindAssociatedFile(const TensorMetadata* metadata, 38 const AssociatedFileType file_type, 39 const std::string& tensor_identifier, 40 ErrorReporter* err); 41 42 /// Find the first normalization unit. If none, return -1. 43 int FindNormalizationUnit(const TensorMetadata* metadata, 44 const std::string& tensor_identifier, 45 ErrorReporter* err); 46 47 } // namespace codegen 48 } // namespace support 49 } // namespace tflite 50 51 #endif // TENSORFLOW_TENSORFLOW_LITE_SUPPORT_CODEGEN_METADATA_HELPER_H_ 52