提交 adb4aa62 编写于 作者: H haozech 提交者: peiyang

add shared params. test=develop

上级 f66e4a5e
...@@ -80,11 +80,18 @@ class LITE_API Predictor { ...@@ -80,11 +80,18 @@ class LITE_API Predictor {
const std::vector<Place>& valid_places, const std::vector<Place>& valid_places,
const std::vector<std::string>& passes = {}); const std::vector<std::string>& passes = {});
std::shared_ptr<Predictor> Clone() const { std::shared_ptr<Predictor> Clone(
cosnst std::vector<std::string> var_names) const {
// CHECK(program_desc_) << "Both program and scope of current predicotr // CHECK(program_desc_) << "Both program and scope of current predicotr
// should be not be nullptr in Clone mode." ; // should be not be nullptr in Clone mode." ;
// CHECK(scope_) << "Both program and scope of current predicotr should // CHECK(scope_) << "Both program and scope of current predicotr should
// be not be nullptr in Clone mode."; // be not be nullptr in Clone mode.";
for (auto i : var_names) {
exec_scope_->Var(i);
auto* tensor = scope_->Var(i)->GetMutable<lite::Tensor>();
auto* sub_tensor = exec_scope_->Var(i)->GetMutable<lite::Tensor>();
sub_tensor->CopyDataFrom(tensor);
}
auto predictor = auto predictor =
std::make_shared<Predictor>(program_desc_, scope_, valid_places_); std::make_shared<Predictor>(program_desc_, scope_, valid_places_);
return predictor; return predictor;
......
...@@ -119,10 +119,11 @@ void CxxPaddleApiImpl::Run() { ...@@ -119,10 +119,11 @@ void CxxPaddleApiImpl::Run() {
raw_predictor_->Run(); raw_predictor_->Run();
} }
std::shared_ptr<lite_api::PaddlePredictor> CxxPaddleApiImpl::Clone() { std::shared_ptr<lite_api::PaddlePredictor> CxxPaddleApiImpl::Clone(
cosnst std::vector<std::string> var_names) {
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
auto predictor = auto predictor = std::make_shared<lite::CxxPaddleApiImpl>(
std::make_shared<lite::CxxPaddleApiImpl>(raw_predictor_->Clone()); raw_predictor_->Clone(var_names));
status_is_cloned_ = true; status_is_cloned_ = true;
predictor->Init(config_); predictor->Init(config_);
return predictor; return predictor;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册