19#include <tensorflow/lite/kernels/register.h>
20#include <tensorflow/lite/model.h>
30 GenericBackend(
const std::string &path)
32 ::tflite::StderrReporter error_reporter;
34 _model = ::tflite::FlatBufferModel::BuildFromFile(path.c_str(), &error_reporter);
36 ::tflite::ops::builtin::BuiltinOpResolver resolver;
37 ::tflite::InterpreterBuilder builder(*_model, resolver);
39 if (kTfLiteOk != builder(&_interp))
41 throw std::runtime_error{
"Failed to build a tflite interpreter"};
44 _interp->SetNumThreads(1);
48 ::tflite::Interpreter &
interpreter(
void)
override {
return *_interp; }
51 std::unique_ptr<::tflite::FlatBufferModel> _model;
52 std::unique_ptr<::tflite::Interpreter> _interp;
62 return std::make_unique<GenericBackend>(args.at(0));
virtual ::tflite::Interpreter & interpreter(void)=0
std::unique_ptr< nnkit::Backend > make_backend(const nnkit::CmdlineArguments &args)