#ifndef TENSORFLOW_LITE_INTERPRETER_TEST_UTIL_H_ #define TENSORFLOW_LITE_INTERPRETER_TEST_UTIL_H_ /* Copyright 2021 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include #include #include #include #include #include #include "tensorflow/lite/internal/signature_def.h" #include "tensorflow/lite/interpreter.h" #include "tensorflow/lite/kernels/internal/compatibility.h" #include "tensorflow/lite/string_util.h" namespace tflite { // InterpreterTest is a friend of Interpreter, so it can access context_. class InterpreterTest : public ::testing::Test { public: template static TfLiteStatus ModifyGraphWithDelegate( Interpreter* interpreter, std::unique_ptr delegate) { return interpreter->ModifyGraphWithDelegate(std::move(delegate)); } protected: TfLiteContext* GetInterpreterContext() { return interpreter_.context_; } std::vector* mutable_lazy_delegate_providers() { return &interpreter_.lazy_delegate_providers_; } bool HasDelegates() { return interpreter_.HasDelegates(); } void BuildSignature(const std::string& signature_key, const std::map& inputs, const std::map& outputs) { internal::SignatureDef signature; signature.inputs = inputs; signature.outputs = outputs; signature.signature_key = signature_key; signature.subgraph_index = 0; interpreter_.SetSignatureDef({signature}); } TfLiteStatus SetExecutionPlan(const std::vector& new_plan) { return interpreter_.SetExecutionPlan(new_plan); } Interpreter interpreter_; }; } // namespace tflite #endif // TENSORFLOW_LITE_INTERPRETER_TEST_UTIL_H_