Skip to content

Commit 0d57626

Browse files
committed
clone
1 parent d06a1f3 commit 0d57626

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

lite/api/cxx_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class LITE_API Predictor {
245245
std::map<TargetType, std::shared_ptr<void>> target_configs_;
246246
std::shared_ptr<cpp::ProgramDesc> program_desc_;
247247
std::shared_ptr<Scope> scope_;
248-
Scope* exec_scope_;
248+
Scope* exec_scope_{nullptr};
249249
std::shared_ptr<RuntimeProgram> program_;
250250
bool program_generated_{false};
251251
std::vector<std::string> input_names_;

lite/core/optimizer/mir/fusion/__xpu__multi_encoder_fuse_pass.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ class XPUMultiEncoderFuser {
19061906
if (is_qkv_already_fusion_) {
19071907
end = i + 1;
19081908
}
1909-
scope->NewTensor(update_tag);
1909+
scope->MutableParent()->NewTensor(update_tag);
19101910
// Update weight, including tranpose\convert type\fuse qkv
19111911
// weight\findmax.
19121912
update_weight(scope,

lite/core/optimizer/mir/type_target_cast_pass.cc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,15 @@ void TypeTargetTransformPass::AddInputIoCopyInst(
274274
// So there will be a new Argument node and a new IoCopy Statement Node.
275275

276276
CHECK(in->IsArg());
277-
auto io_copy_output_name =
277+
bool in_persist = in->AsArg().is_weight || in->AsArg().is_persist;
278+
std::string io_copy_output_name;
279+
if(in_persist){
280+
io_copy_output_name =
281+
string_format("%s/target_trans_persistable", in->AsArg().name.c_str());
282+
}else{
283+
io_copy_output_name =
278284
string_format("%s/target_trans", in->AsArg().name.c_str());
285+
}
279286

280287
if (copied_nodes->count(in->AsArg().name)) {
281288
// Remove the old link
@@ -292,7 +299,12 @@ void TypeTargetTransformPass::AddInputIoCopyInst(
292299
// TODO(MyPandaShaoxiang) should set same place with input?
293300
auto* io_copy_output_arg = graph->NewArgumentNode(io_copy_output_name);
294301
// Create the new var manually.
295-
auto new_var = inst_node->AsStmt().op()->scope()->Var(io_copy_output_name);
302+
Variable* new_var=nullptr;
303+
if(in_persist){
304+
new_var = inst_node->AsStmt().op()->scope()->MutableParent()->Var(io_copy_output_name);
305+
}else{
306+
new_var = inst_node->AsStmt().op()->scope()->Var(io_copy_output_name);
307+
}
296308
// Set the place for io_copy_output_arg node, the target should be equal to
297309
// to.target()
298310
// The precision and layout should be equal to from.precision(),
@@ -316,7 +328,6 @@ void TypeTargetTransformPass::AddInputIoCopyInst(
316328
}
317329
auto* io_copy_inst = graph->NewInstructNode();
318330

319-
bool in_persist = in->AsArg().is_weight || in->AsArg().is_persist;
320331
std::string io_copy_type = in_persist ? "io_copy_once" : "io_copy";
321332
io_copy_output_arg->AsArg().is_persist = in_persist;
322333
// create Op and kernels.

lite/core/program.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,12 @@ void Program::PrepareWorkspace(
718718
// Create tensors or weights from variable description.
719719
if (!var_desc->Persistable()) {
720720
vars_.push_back(var_name);
721-
auto* var = exec_scope_->Var(var_name);
721+
Variable* var=nullptr;
722+
if(var_name.find("/target_trans_persistable")!=std::string::npos){
723+
var = scope_->Var(var_name);
724+
}else{
725+
var = exec_scope_->Var(var_name);
726+
}
722727
if (var_type == lite::VarDescAPI::Type::LOD_TENSOR) {
723728
const auto& var_data_type =
724729
VarDescType2PrecisionType(var_desc->GetDataType());

0 commit comments

Comments
 (0)