From 4ab0b6ddb14b660a2245dde2aa4f95b6cf869fe2 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 22 Oct 2024 12:58:54 -0700 Subject: [PATCH] FlatBufferModel verification crashes on some Windows instances. This change disables it until the root cause is found. PiperOrigin-RevId: 688659191 --- tensorflow_lite_support/cc/task/core/tflite_engine.cc | 6 ++++++ tensorflow_lite_support/metadata/cc/metadata_extractor.cc | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/tensorflow_lite_support/cc/task/core/tflite_engine.cc b/tensorflow_lite_support/cc/task/core/tflite_engine.cc index 4e45c4f32..14f4e2eb3 100644 --- a/tensorflow_lite_support/cc/task/core/tflite_engine.cc +++ b/tensorflow_lite_support/cc/task/core/tflite_engine.cc @@ -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 resolver) diff --git a/tensorflow_lite_support/metadata/cc/metadata_extractor.cc b/tensorflow_lite_support/metadata/cc/metadata_extractor.cc index f4ee9192f..db6782691 100644 --- a/tensorflow_lite_support/metadata/cc/metadata_extractor.cc +++ b/tensorflow_lite_support/metadata/cc/metadata_extractor.cc @@ -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(buffer_data), buffer_size); if (!tflite::VerifyModelBuffer(verifier)) { @@ -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