Address review comments
This commit is contained in:
parent
6f953837fa
commit
6e78bac799
@ -271,11 +271,13 @@ DS_CreateModel(const char* aModelPath,
|
||||
return DS_ERR_NO_MODEL;
|
||||
}
|
||||
|
||||
std::unique_ptr<ModelState> model(
|
||||
#ifndef USE_TFLITE
|
||||
std::unique_ptr<ModelState> model(new TFModelState());
|
||||
new TFModelState()
|
||||
#else
|
||||
std::unique_ptr<ModelState> model(new TFLiteModelState());
|
||||
#endif // USE_TFLITE
|
||||
new TFLiteModelState()
|
||||
#endif
|
||||
);
|
||||
|
||||
if (!model) {
|
||||
std::cerr << "Could not allocate model state." << std::endl;
|
||||
|
@ -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<int>& list, int value)
|
||||
void
|
||||
push_back_if_not_present(std::deque<int>& 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<float>& samples, vector<float>& 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;
|
||||
|
@ -32,6 +32,7 @@ struct TFLiteModelState : public ModelState
|
||||
std::vector<int> mfcc_exec_plan_;
|
||||
|
||||
TFLiteModelState();
|
||||
virtual ~TFLiteModelState();
|
||||
|
||||
virtual int init(const char* model_path,
|
||||
unsigned int n_features,
|
||||
|
Loading…
Reference in New Issue
Block a user