Skip to content

Commit

Permalink
FlatBufferModel verification crashes on some Windows instances. This …
Browse files Browse the repository at this point in the history
…change disables it until the root cause is found.

PiperOrigin-RevId: 688659191
  • Loading branch information
tensorflower-gardener authored and tflite-support-robot committed Oct 22, 2024
1 parent 30e75df commit 4ab0b6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tensorflow_lite_support/cc/task/core/tflite_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ using ::tflite::support::TfLiteSupportStatus;

bool TfLiteEngine::Verifier::Verify(const char* data, int length,
tflite::ErrorReporter* reporter) {
// TODO(b/366118885): Remove after the root cause of the crash on Windows
// is found.
#if defined(_WIN32)
return true;
#else
return tflite::Verify(data, length, reporter);
#endif
}

TfLiteEngine::TfLiteEngine(std::unique_ptr<tflite::OpResolver> resolver)
Expand Down
5 changes: 5 additions & 0 deletions tensorflow_lite_support/metadata/cc/metadata_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ absl::Status ModelMetadataExtractor::InitFromModelBuffer(
// Rely on the simplest, base flatbuffers verifier. Here is not the place to
// e.g. use an OpResolver: we just want to make sure the buffer is valid to
// access the metadata.
// TODO(b/366118885): Remove after the root cause of the crash on Windows
// is found.
#if !defined(_WIN32)
flatbuffers::Verifier verifier = flatbuffers::Verifier(
reinterpret_cast<const uint8_t*>(buffer_data), buffer_size);
if (!tflite::VerifyModelBuffer(verifier)) {
Expand All @@ -191,6 +194,8 @@ absl::Status ModelMetadataExtractor::InitFromModelBuffer(
"The model is not a valid FlatBuffer buffer.",
TfLiteSupportStatus::kInvalidFlatBufferError);
}
#endif

model_ = tflite::GetModel(buffer_data);
if (model_->metadata() == nullptr) {
// Not all models have metadata, which is OK. `GetModelMetadata()` then
Expand Down

0 comments on commit 4ab0b6d

Please sign in to comment.