未验证 提交 7ebbcbbc 编写于 作者: W wanghuancoder 提交者: GitHub

add no need buffer check, test=develop (#35790)

上级 7ba69249
......@@ -209,6 +209,23 @@ void InterpreterCore::Convert() {
}
}
bool InterpreterCore::BuildInplaceCheckVarIsOnlyInput(size_t var_index) {
if (!global_scope_->vec_meta_info_[var_index].vardesc_) {
return input_var2op_info_[var_index].size() == 1;
} else {
int is_input_cnt = 0;
for (auto inst_id : input_var2op_info_[var_index]) {
OpInOutInfo info;
info.Build(vec_instruction_[inst_id].kernel_func_.operator_base_);
if (info.IsInArgBufferNeeded(
global_scope_->vec_meta_info_[var_index].vardesc_->Name())) {
is_input_cnt++;
}
}
return is_input_cnt == 1;
}
}
void InterpreterCore::BuildInplace() {
for (size_t i = 0; i < vec_instruction_.size(); ++i) {
if (!vec_instruction_[i]
......@@ -224,7 +241,7 @@ void InterpreterCore::BuildInplace() {
for (auto& pair : in_to_outs) {
auto iter = vec_instruction_[i].input_index_.find(pair.first);
if (iter != vec_instruction_[i].input_index_.end()) {
if (input_var2op_info_[iter->second[0]].size() == 1) {
if (BuildInplaceCheckVarIsOnlyInput(iter->second[0])) {
auto iterout = vec_instruction_[i].output_index_.find(pair.second);
if (iterout != vec_instruction_[i].output_index_.end()) {
auto invar = global_scope_->var_list[iter->second[0]];
......@@ -232,6 +249,15 @@ void InterpreterCore::BuildInplace() {
if (invar && outvar) {
vec_instruction_[i].vec_inplace_in_to_out_.emplace_back(invar,
outvar);
VLOG(3) << "inplace "
<< vec_instruction_[i].kernel_func_.operator_base_->Type()
<< " "
<< global_scope_->vec_meta_info_[iter->second[0]]
.vardesc_->Name()
<< " -> "
<< global_scope_->vec_meta_info_[iterout->second[0]]
.vardesc_->Name()
<< std::endl;
}
}
}
......
......@@ -57,6 +57,8 @@ class InterpreterCore {
void BuildInplace();
bool BuildInplaceCheckVarIsOnlyInput(size_t var_index);
void RunInstruction(const Instruction& instr_node);
void ExecuteInstructionList(const std::vector<Instruction>& vec_instr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册