tensorflow/lite/c/c_api_experimental_test.cc
// Test that when using TfLiteInterpreterCreateWithSelectedOps,
// we do NOT get the standard builtin operators by default.
Test that when using TfLiteInterpreterCreateWithSelectedOps,
we do NOT get the standard builtin operators by default.
Test that when using TfLiteInterpreterCreateWithSelectedOps we do NOT get the standard builtin operators by default .
TEST(CApiExperimentalTest, MissingBuiltin) {
  TfLiteModel* model =
      TfLiteModelCreateFromFile("tensorflow/lite/testdata/add.bin");
  ASSERT_NE(model, nullptr);
  tflite::TestErrorReporter reporter;
  TfLiteInterpreterOptions* options = TfLiteInterpreterOptionsCreate();
  TfLiteInterpreterOptionsSetErrorReporter(
      options,
      [](void* user_data, const char* format, va_list args) {
        reinterpret_cast<tflite::TestErrorReporter*>(user_data)->Report(format,
                                                                        args);
      },
      &reporter);
  TfLiteInterpreter* interpreter =
      TfLiteInterpreterCreateWithSelectedOps(model, options);
  ASSERT_EQ(interpreter, nullptr);
  EXPECT_THAT(
      reporter.error_messages(),
      HasSubstr("Didn't find op for builtin opcode 'ADD' version '1'."));
  EXPECT_EQ(reporter.num_calls(), 2);
  TfLiteInterpreterDelete(interpreter);
  TfLiteInterpreterOptionsDelete(options);
  TfLiteModelDelete(model);
}
TEST ( CApiExperimentalTest , MissingBuiltin ) { TfLiteModel * model = TfLiteModelCreateFromFile ( " " ) ; ASSERT_NE ( model , nullptr ) ; tflite :: TestErrorReporter reporter ; TfLiteInterpreterOptions * options = TfLiteInterpreterOptionsCreate ( ) ; TfLiteInterpreterOptionsSetErrorReporter ( options , [ ] ( void * user_data , const char * format , va_list args ) { reinterpret_cast < tflite :: TestErrorReporter * > ( user_data ) -> Report ( format , args ) ; } , & reporter ) ; TfLiteInterpreter * interpreter = TfLiteInterpreterCreateWithSelectedOps ( model , options ) ; ASSERT_EQ ( interpreter , nullptr ) ; EXPECT_THAT ( reporter . error_messages ( ) , HasSubstr ( " " ) ) ; EXPECT_EQ ( reporter . num_calls ( ) , 2 ) ; TfLiteInterpreterDelete ( interpreter ) ; TfLiteInterpreterOptionsDelete ( options ) ; TfLiteModelDelete ( model ) ; }
Test that when using TfLiteInterpreterCreateWithSelectedOps,
we do NOT get the standard builtin operators by default.
Test that when using TfLiteInterpreterCreateWithSelectedOps we do NOT get the standard builtin operators by default .
// Install a custom error reporter into the interpreter by way of options. // Create an interpreter with no builtins at all. // Check that interpreter creation failed, because the model contain a buitin // op that wasn't supported, and that we got the expected error messages.