diff --git a/native_client/deepspeech.cc b/native_client/deepspeech.cc index f0ea0ee612..a4e976a04a 100644 --- a/native_client/deepspeech.cc +++ b/native_client/deepspeech.cc @@ -275,11 +275,12 @@ DS_CreateModel(const char* aModelPath, return DS_ERR_NO_MODEL; } + std::unique_ptr model( #ifndef USE_TFLITE - std::unique_ptr model(new TFModelState()); + new TFModelState() #else - std::unique_ptr model(new TFLiteModelState()); -#endif // USE_TFLITE + new TFLiteModelState() + ); if (!model) { std::cerr << "Could not allocate model state." << std::endl; diff --git a/native_client/tflitemodelstate.cc b/native_client/tflitemodelstate.cc index f1e9753905..92d9c01472 100644 --- a/native_client/tflitemodelstate.cc +++ b/native_client/tflitemodelstate.cc @@ -35,7 +35,8 @@ tflite_get_output_tensor_by_name(const Interpreter* interpreter, const char* nam return interpreter->outputs()[idx]; } -void push_back_if_not_present(std::deque& list, int value) +void +push_back_if_not_present(std::deque& list, int value) { if (std::find(list.begin(), list.end(), value) == list.end()) { list.push_back(value); @@ -86,6 +87,10 @@ TFLiteModelState::TFLiteModelState() { } +TFLiteModelState::~TFLiteModelState() +{ +} + int TFLiteModelState::init(const char* model_path, unsigned int n_features, @@ -235,8 +240,13 @@ TFLiteModelState::compute_mfcc(const vector& samples, vector& mfcc input_samples[i] = samples[i]; } - interpreter_->SetExecutionPlan(mfcc_exec_plan_); - TfLiteStatus status = interpreter_->Invoke(); + TfLiteStatus status = interpreter_->SetExecutionPlan(mfcc_exec_plan_); + if (status != kTfLiteOk) { + std::cerr << "Error setting execution plan: " << status << "\n"; + return; + } + + status = interpreter_->Invoke(); if (status != kTfLiteOk) { std::cerr << "Error running session: " << status << "\n"; return; diff --git a/native_client/tflitemodelstate.h b/native_client/tflitemodelstate.h index de02074dbe..ee5bfb6a91 100644 --- a/native_client/tflitemodelstate.h +++ b/native_client/tflitemodelstate.h @@ -32,6 +32,7 @@ struct TFLiteModelState : public ModelState std::vector mfcc_exec_plan_; TFLiteModelState(); + virtual ~TFLiteModelState(); virtual int init(const char* model_path, unsigned int n_features,