From 89dd5837aa3a0a5d5ccd39f7c963b668eebbaab4 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" <gardener@tensorflow.org> Date: Thu, 7 Jan 2021 06:15:41 -0800 Subject: [PATCH] Hint at the problem in the "Didn't find op for builtin opcode ... version ..." error. PiperOrigin-RevId: 350545885 Change-Id: I18528ab009bbb6e6a30e67e683ebdb1fe3ba00d0 --- tensorflow/lite/c/c_api_experimental_test.cc | 8 +++++--- tensorflow/lite/core/api/op_resolver.cc | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tensorflow/lite/c/c_api_experimental_test.cc b/tensorflow/lite/c/c_api_experimental_test.cc index 0d54b7e7885..2670861d787 100644 --- a/tensorflow/lite/c/c_api_experimental_test.cc +++ b/tensorflow/lite/c/c_api_experimental_test.cc @@ -20,6 +20,7 @@ limitations under the License. #include <memory> #include <vector> +#include <gmock/gmock.h> #include <gtest/gtest.h> #include "tensorflow/lite/builtin_ops.h" #include "tensorflow/lite/c/c_api.h" @@ -27,6 +28,7 @@ limitations under the License. #include "tensorflow/lite/delegates/delegate_test_util.h" #include "tensorflow/lite/testing/util.h" +using testing::HasSubstr; using tflite::delegates::test_utils::TestDelegate; namespace { @@ -108,9 +110,9 @@ TEST(CApiExperimentalTest, MissingBuiltin) { // Check that interpreter creation failed, because the model contain a buitin // op that wasn't supported, and that we got the expected error messages. ASSERT_EQ(interpreter, nullptr); - EXPECT_EQ(reporter.error_messages(), - "Didn't find op for builtin opcode 'ADD' version '1'\n" - "Registration failed.\n"); + EXPECT_THAT( + reporter.error_messages(), + HasSubstr("Didn't find op for builtin opcode 'ADD' version '1'.")); EXPECT_EQ(reporter.num_calls(), 2); TfLiteInterpreterDelete(interpreter); diff --git a/tensorflow/lite/core/api/op_resolver.cc b/tensorflow/lite/core/api/op_resolver.cc index c5dffb63549..04ebd9a7d5c 100644 --- a/tensorflow/lite/core/api/op_resolver.cc +++ b/tensorflow/lite/core/api/op_resolver.cc @@ -43,7 +43,9 @@ TfLiteStatus GetRegistrationFromOpCode( if (*registration == nullptr) { TF_LITE_REPORT_ERROR( error_reporter, - "Didn't find op for builtin opcode '%s' version '%d'\n", + "Didn't find op for builtin opcode '%s' version '%d'. " + "An older version of this builtin might be supported. " + "Are you using an old TFLite binary with a newer model?\n", EnumNameBuiltinOperator(builtin_code), version); status = kTfLiteError; }