Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
shentanyue committed Feb 24, 2023
1 parent 3d2fb00 commit 14ee890
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
20 changes: 12 additions & 8 deletions lite/api/light_api_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,19 @@ void LightPredictorImpl::Init(const lite_api::MobileConfig& config) {
config.is_model_from_memory(),
lite_api::LiteModelType::kNaiveBuffer,
use_low_precision));
} else if (!config.lite_model_file().empty() &&
!config.is_model_from_memory()) {
raw_predictor_.reset(
new LightPredictor(config.lite_model_file(), use_low_precision));
} else if (!config.lite_model_file().empty() &&
config.is_model_from_memory()) {
raw_predictor_.reset(new LightPredictor(config.lite_model_file().c_str(),
config.lite_model_file().length(),
use_low_precision));
} else {
if (config.is_model_from_memory()) {
raw_predictor_.reset(new LightPredictor(config.lite_model_buffer(),
config.lite_model_buffer_size(),
use_low_precision));
} else {
raw_predictor_.reset(
new LightPredictor(config.lite_model_file(), use_low_precision));
}
raw_predictor_.reset(new LightPredictor(config.lite_model_buffer(),
config.lite_model_buffer_size(),
use_low_precision));
}

mode_ = config.power_mode();
Expand Down
6 changes: 2 additions & 4 deletions lite/api/paddle_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -734,14 +734,12 @@ void MobileConfig::set_model_from_file(const std::string &x) {
}

void MobileConfig::set_model_from_buffer(const std::string &x) {
lite_model_buffer_ = x.c_str();
lite_model_buffer_size_ = x.length();
lite_model_file_ = x;
model_from_memory_ = true;
}

void MobileConfig::set_model_from_buffer(std::string &&x) {
lite_model_buffer_ = std::forward<std::string>(x).c_str();
lite_model_buffer_size_ = std::forward<std::string>(x).length();
lite_model_file_.assign(std::forward<std::string>(x));
model_from_memory_ = true;
}

Expand Down
1 change: 1 addition & 0 deletions lite/model_parser/model_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ void LoadModelNaiveFromMemory(const char *model_buffer,
break;
}
}

#ifndef LITE_ON_TINY_PUBLISH
void LoadModelNaiveV0FromMemory(const std::string &model_buffer,
Scope *scope,
Expand Down

0 comments on commit 14ee890

Please sign in to comment.