MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / VerifyAndBuildFromFile

Method VerifyAndBuildFromFile

tensorflow/lite/model.cc:90–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90std::unique_ptr<FlatBufferModel> FlatBufferModel::VerifyAndBuildFromFile(
91 const char* filename, TfLiteVerifier* extra_verifier,
92 ErrorReporter* error_reporter) {
93 error_reporter = ValidateErrorReporter(error_reporter);
94
95 std::unique_ptr<FlatBufferModel> model;
96 auto allocation = GetAllocationFromFile(filename, /*mmap_file=*/true,
97 error_reporter, /*use_nnapi=*/true);
98
99 flatbuffers::Verifier base_verifier(
100 reinterpret_cast<const uint8_t*>(allocation->base()),
101 allocation->bytes());
102 if (!VerifyModelBuffer(base_verifier)) {
103 error_reporter->Report("The model is not a valid Flatbuffer file");
104 return nullptr;
105 }
106
107 if (extra_verifier &&
108 !extra_verifier->Verify(static_cast<const char*>(allocation->base()),
109 allocation->bytes(), error_reporter)) {
110 return model;
111 }
112 model.reset(new FlatBufferModel(std::move(allocation), error_reporter));
113 if (!model->initialized()) model.reset();
114 return model;
115}
116#endif
117
118std::unique_ptr<FlatBufferModel> FlatBufferModel::BuildFromBuffer(

Callers

nothing calls this directly

Calls 9

ValidateErrorReporterFunction · 0.85
GetAllocationFromFileFunction · 0.85
VerifyModelBufferFunction · 0.85
baseMethod · 0.45
bytesMethod · 0.45
ReportMethod · 0.45
VerifyMethod · 0.45
resetMethod · 0.45
initializedMethod · 0.45

Tested by

no test coverage detected