| @@ -1514,7 +1514,7 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector< | |||
| output_list = last_peer_out_op_desc->GetOutputOffset(); | |||
| auto out_index = static_cast<unsigned long>(peer_out_anchor->GetIdx()); | |||
| if (output_list.size() > static_cast<size_t>(out_index)) { | |||
| int64_t peer_out_inner_offset; | |||
| int64_t peer_out_inner_offset = 0; | |||
| if (ge::AttrUtils::GetInt(last_peer_out_op_desc->MutableOutputDesc(out_index), ATTR_NAME_INNER_OFFSET, | |||
| peer_out_inner_offset)) { | |||
| (void)ge::AttrUtils::SetInt(tmp_op_desc->MutableInputDesc(anchor->GetIdx()), ATTR_NAME_INNER_OFFSET, | |||
| @@ -1534,7 +1534,7 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector< | |||
| GE_ERRORLOG_AND_ERRORMSG(ge::FAILED, error.c_str()); | |||
| return ge::FAILED; | |||
| } | |||
| int64_t inner_offset; | |||
| int64_t inner_offset = 0; | |||
| (void)ge::AttrUtils::GetInt(tmp_op_desc->MutableInputDesc(anchor->GetIdx()), ATTR_NAME_INNER_OFFSET, | |||
| inner_offset); | |||
| GELOGD("Node[%s] input[%d] has origin offset[%ld] origin_inner_offset[%ld]", tmp_op_desc->GetName().c_str(), | |||
| @@ -1575,7 +1575,7 @@ ge::Status GraphMemoryAssigner::UpdateRefOpOutputOffset(const NodePtr &node, con | |||
| const int ref_in, const int64_t input_offset) const { | |||
| auto opdesc = node->GetOpDesc(); | |||
| GE_CHECK_NOTNULL(opdesc); | |||
| int64_t inner_offset; | |||
| int64_t inner_offset = 0; | |||
| bool has_inner_offset = ge::AttrUtils::GetInt(opdesc->MutableInputDesc(ref_in), ATTR_NAME_INNER_OFFSET, inner_offset); | |||
| for (const auto &out2in : out2ins) { | |||
| auto out_i = out2in.first; | |||
| @@ -1591,7 +1591,7 @@ ge::Status GraphMemoryAssigner::UpdateRefOpOutputOffset(const NodePtr &node, con | |||
| origin_output_list[out_i] = input_offset; | |||
| opdesc->SetOutputOffset(origin_output_list); | |||
| if (has_inner_offset) { | |||
| (void)ge::AttrUtils::SetInt(opdesc->MutableOutputDesc(out_i), ATTR_NAME_INNER_OFFSET,inner_offset); | |||
| (void)ge::AttrUtils::SetInt(opdesc->MutableOutputDesc(out_i), ATTR_NAME_INNER_OFFSET, inner_offset); | |||
| } | |||
| GELOGI("Node[%s] output[%d] is updated from reuse input index[%d] to offset[%ld], inner_offset[%ld]", opdesc->GetName().c_str(), | |||
| out_i, ref_in, input_offset, inner_offset); | |||
| @@ -342,7 +342,7 @@ vector<void *> ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co | |||
| int64_t input_offset = v_input_offset[non_const_index]; | |||
| non_const_index++; | |||
| int64_t inner_offset; | |||
| int64_t inner_offset = 0; | |||
| (void)ge::AttrUtils::GetInt(op_desc->MutableInputDesc(i), ATTR_NAME_INNER_OFFSET, inner_offset); | |||
| GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(input_offset - inner_offset), | |||
| uint8_t *variable_addr = nullptr; | |||
| @@ -454,7 +454,7 @@ vector<void *> ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C | |||
| GELOGD("%s is an optional output, the address don't need to be saved.", tensor_desc->GetName().c_str()); | |||
| continue; | |||
| } | |||
| int64_t inner_offset; | |||
| int64_t inner_offset = 0; | |||
| (void)ge::AttrUtils::GetInt(op_desc->MutableOutputDesc(i), ATTR_NAME_INNER_OFFSET, inner_offset); | |||
| GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(v_output_offset[i] - inner_offset), | |||
| uint8_t *variable_addr = nullptr; | |||
| @@ -503,6 +503,24 @@ TEST_F(UtestMemoryAssignerTest, graph_memory_assign_set_input_offset) { | |||
| EXPECT_EQ(memoryAssigner.CheckOffset(), GRAPH_SUCCESS); | |||
| } | |||
| TEST_F(UtestMemoryAssignerTest, graph_memory_assign_check_inner_offset) { | |||
| ge::ComputeGraphPtr graph = MakeRefNodeGraph(); | |||
| auto assign = graph->FindNode("assgin"); | |||
| auto op_desc = assign->GetOpDesc(); | |||
| int64_t inner_offset = 0; | |||
| EXPECT_EQ(ge::AttrUtils::GetInt(op_desc->MutableInputDesc(0), ATTR_NAME_INNER_OFFSET, inner_offset), false); | |||
| EXPECT_EQ(ge::AttrUtils::GetInt(op_desc->MutableInputDesc(1), ATTR_NAME_INNER_OFFSET, inner_offset), false); | |||
| GraphMemoryAssigner memoryAssigner(graph); | |||
| MemoryOffset memory_offset(RT_MEMORY_HBM, 0); | |||
| memoryAssigner.memory_offset_.emplace(RT_MEMORY_HBM, memory_offset); | |||
| EXPECT_EQ(memoryAssigner.SetInputOffset(), GRAPH_SUCCESS); | |||
| EXPECT_EQ(ge::AttrUtils::GetInt(op_desc->MutableInputDesc(0), ATTR_NAME_INNER_OFFSET, inner_offset), true); | |||
| EXPECT_EQ(inner_offset, 100); | |||
| EXPECT_EQ(ge::AttrUtils::GetInt(op_desc->MutableOutputDesc(0), ATTR_NAME_INNER_OFFSET, inner_offset), true); | |||
| EXPECT_EQ(inner_offset, 100); | |||
| EXPECT_EQ(ge::AttrUtils::GetInt(op_desc->MutableInputDesc(1), ATTR_NAME_INNER_OFFSET, inner_offset), false); | |||
| } | |||
| TEST_F(UtestMemoryAssignerTest, graph_memory_assign_update_ref_op_offset_reverse) { | |||
| ge::ut::GraphBuilder builder("graph"); | |||
| auto data_input = builder.AddNode("data", "Data", 1, 1); | |||