From 4726e4abc95db2f8a243bd445dfc27562ae56227 Mon Sep 17 00:00:00 2001 From: Bernardo Henz Date: Mon, 28 Sep 2020 11:17:30 -0300 Subject: [PATCH] Loading tflite buffer from buffer working --- native_client/tflitemodelstate.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/native_client/tflitemodelstate.cc b/native_client/tflitemodelstate.cc index 8d780fe2a6..b72b1fa1ae 100755 --- a/native_client/tflitemodelstate.cc +++ b/native_client/tflitemodelstate.cc @@ -164,7 +164,10 @@ TFLiteModelState::init(const std::string &model_string, bool init_from_bytes) } if (init_from_bytes){ - fbmodel_ = tflite::FlatBufferModel::BuildFromBuffer(model_string.c_str(), model_string.size_t); + char *tmp_buffer = new char[model_string.size()]; + std::copy(model_string.begin(), model_string.end(), tmp_buffer); + // Using c_str does not work + fbmodel_ = tflite::FlatBufferModel::VerifyAndBuildFromBuffer(tmp_buffer,model_string.size()); if (!fbmodel_) { std::cerr << "Error at reading model buffer " << std::endl; return DS_ERR_FAIL_INIT_MMAP; @@ -177,7 +180,6 @@ TFLiteModelState::init(const std::string &model_string, bool init_from_bytes) } } - tflite::ops::builtin::BuiltinOpResolver resolver; tflite::InterpreterBuilder(*fbmodel_, resolver)(&interpreter_); if (!interpreter_) {