#include "tensorflow_lite_support/metadata/cc/metadata_extractor.h"
#include <string>
#include "absl/memory/memory.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "flatbuffers/flatbuffers.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow_lite_support/cc/common.h"
#include "tensorflow_lite_support/cc/port/status_macros.h"
#include "tensorflow_lite_support/metadata/cc/utils/zip_readonly_mem_file.h"
#include "tensorflow_lite_support/metadata/metadata_schema_generated.h"
#include "third_party/zlib/contrib/minizip/ioapi.h"
#include "third_party/zlib/contrib/minizip/unzip.h"
namespace tflite {
namespace metadata {
namespace {
constexpr char kMetadataBufferName[] = …;
StatusCode;
Offset;
Vector;
TensorMetadata;
CreateStatusWithPayload;
TfLiteSupportStatus;
template <typename T>
const T* GetItemFromVector(
const flatbuffers::Vector<flatbuffers::Offset<T>>* src_vector, int index) { … }
absl::Status UnzipErrorToStatus(int error) { … }
struct ZipFileInfo { … };
tflite::support::StatusOr<ZipFileInfo> GetCurrentZipFileInfo(
const unzFile& zf) { … }
}
tflite::support::StatusOr<std::unique_ptr<ModelMetadataExtractor>>
ModelMetadataExtractor::CreateFromModelBuffer(const char* buffer_data,
size_t buffer_size) { … }
tflite::support::StatusOr<const tflite::ProcessUnit*>
ModelMetadataExtractor::FindFirstProcessUnit(
const tflite::TensorMetadata& tensor_metadata,
tflite::ProcessUnitOptions type) { … }
std::string ModelMetadataExtractor::FindFirstAssociatedFileName(
const tflite::TensorMetadata& tensor_metadata,
tflite::AssociatedFileType type, absl::string_view locale) { … }
absl::Status ModelMetadataExtractor::InitFromModelBuffer(
const char* buffer_data, size_t buffer_size) { … }
absl::Status ModelMetadataExtractor::ExtractAssociatedFiles(
const char* buffer_data, size_t buffer_size) { … }
tflite::support::StatusOr<absl::string_view>
ModelMetadataExtractor::GetAssociatedFile(const std::string& filename) const { … }
tflite::support::StatusOr<std::string> ModelMetadataExtractor::GetModelVersion()
const { … }
const flatbuffers::Vector<flatbuffers::Offset<tflite::TensorMetadata>>*
ModelMetadataExtractor::GetInputTensorMetadata() const { … }
const tflite::TensorMetadata* ModelMetadataExtractor::GetInputTensorMetadata(
int index) const { … }
int ModelMetadataExtractor::GetInputTensorCount() const { … }
const Vector<Offset<TensorMetadata>>*
ModelMetadataExtractor::GetOutputTensorMetadata() const { … }
const tflite::TensorMetadata* ModelMetadataExtractor::GetOutputTensorMetadata(
int index) const { … }
int ModelMetadataExtractor::GetOutputTensorCount() const { … }
const Vector<flatbuffers::Offset<tflite::ProcessUnit>>*
ModelMetadataExtractor::GetInputProcessUnits() const { … }
const tflite::ProcessUnit* ModelMetadataExtractor::GetInputProcessUnit(
int index) const { … }
int ModelMetadataExtractor::GetInputProcessUnitsCount() const { … }
const Vector<flatbuffers::Offset<tflite::ProcessUnit>>*
ModelMetadataExtractor::GetOutputProcessUnits() const { … }
const tflite::ProcessUnit* ModelMetadataExtractor::GetOutputProcessUnit(
int index) const { … }
int ModelMetadataExtractor::GetOutputProcessUnitsCount() const { … }
}
}