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 f16f4ee
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
1 change: 0 additions & 1 deletion lite/api/light_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace paddle {
namespace lite {

void LightPredictor::Build(const std::string& lite_model_file) {
LoadModelNaiveFromFile(lite_model_file, scope_.get(), program_desc_.get());
// For weight quantization of post training, load the int8/16 weights
// for optimized model, and dequant it to fp32.
DequantizeWeight();
Expand Down
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 f16f4ee

Please sign in to comment.