From 3781cd7ecc51707142672c47a8c611f9b5562cef Mon Sep 17 00:00:00 2001 From: wangxiaotian22 Date: Wed, 17 Mar 2021 18:36:11 +0800 Subject: [PATCH] suojin --- ge/graph/build/logical_stream_allocator.cc | 33 ++-- ge/graph/build/memory/block_mem_assigner.cc | 164 ++++++++++-------- ge/plugin/engine/CMakeLists.txt | 1 + .../format_transfer_fractal_nz_unittest.cc | 34 ++-- .../format_transfer_nhwc_fractalz_unittest.cc | 16 +- .../ut/ge/common/format_transfer_unittest.cc | 58 +++---- 6 files changed, 165 insertions(+), 141 deletions(-) diff --git a/ge/graph/build/logical_stream_allocator.cc b/ge/graph/build/logical_stream_allocator.cc index 3bc29b70..7c76c104 100644 --- a/ge/graph/build/logical_stream_allocator.cc +++ b/ge/graph/build/logical_stream_allocator.cc @@ -70,7 +70,7 @@ Status AssignByLabelPass::Run(ComputeGraphPtr graph, const vector & auto iter = label_streams.find(stream_label); if (iter == label_streams.end()) { subgraph->stream_id = next_stream; - GELOGI("Assign new stream %ld for label %s.", next_stream, stream_label.c_str()); + GELOGI("[Assign][NewStreamId] %ld for label %s.", next_stream, stream_label.c_str()); label_streams.emplace(stream_label, next_stream); next_stream++; @@ -102,7 +102,7 @@ Status IndependentStreamPass::Run(ComputeGraphPtr graph, const vectorstream_id = next_stream; - GELOGI("Assign new independent stream %ld for engine %s (label: %s).", next_stream, engine.c_str(), + GELOGI("[Assign][NewStreamId:independent] %ld for engine %s (label: %s).", next_stream, engine.c_str(), stream_label.c_str()); label_streams.emplace(stream_label, next_stream); @@ -137,8 +137,8 @@ Status AssignByDependencyPass::Run(ComputeGraphPtr graph, const vectorstream_id = stream_id; - GELOGI("Reusable subgraph %s has not been assigned a stream, now assign new stream %ld.", - reusable_subgraph->name.c_str(), stream_id); + GELOGI("[Assign][NewStreamId] %ld for Reusable subgraph %s cause has not been assigned before.", + stream_id, reusable_subgraph->name.c_str()); } if (reusable_subgraph->reused_subgraph != nullptr) { @@ -147,7 +147,8 @@ Status AssignByDependencyPass::Run(ComputeGraphPtr graph, const vectorreused_subgraph = reusable_subgraph; reused_subgraphs_.emplace_back(subgraph, reusable_subgraph); - GELOGI("Subgraph %s of engine %s reuses stream of subgraph %s of engine %s.", subgraph->name.c_str(), + GELOGI("[Reuse][Stream]Subgraph %s of engine %s reuses stream of subgraph %s of engine %s.", + subgraph->name.c_str(), subgraph->engine_conf.id.c_str(), reusable_subgraph->name.c_str(), reusable_subgraph->engine_conf.id.c_str()); } @@ -259,7 +260,7 @@ int64_t AssignByDependencyPass::AssignNewStream(SubgraphPtr subgraph) { engine_stream_num_[engine_name] = stream_id + 1; } - GELOGI("Subgraph %s assigns new temp stream %ld (engine: %s).", subgraph->name.c_str(), stream_id, + GELOGI("[Assign][NewStreamId:temp]id:%ld for Subgraph %s (engine: %s).", stream_id, subgraph->name.c_str(), engine_name.c_str()); return stream_id; @@ -292,7 +293,7 @@ void AssignByDependencyPass::UpdateAssignedSubgraphs(Context &context) { GELOGI("Subgraph %s of engine %s reuses default stream %ld.", subgraph->name.c_str(), subgraph->engine_conf.id.c_str(), context.default_stream); } else { - GELOGI("Stream of subgraph %s has been updated to %ld.", subgraph->name.c_str(), subgraph->stream_id); + GELOGI("[Update][StreamId]id:%ld for subgraph %s.", subgraph->stream_id, subgraph->name.c_str()); } } } @@ -303,7 +304,7 @@ void AssignByDependencyPass::UpdateReusedSubgraphs() { auto &cur_subgraph = item.first; auto &reused_graph = item.second; cur_subgraph->stream_id = reused_graph->stream_id; - GELOGI("Stream of subgraph %s has been updated to %ld.", cur_subgraph->name.c_str(), cur_subgraph->stream_id); + GELOGI("[Update][StreamId]id:%ld for subgraph %s.", cur_subgraph->stream_id, cur_subgraph->name.c_str()); } } @@ -340,7 +341,7 @@ Status NodeStreamUpdatePass::Run(ComputeGraphPtr graph, const vectorname.c_str(), subgraph->stream_id, + GELOGI("[Assign][StreamId] %ld for Subgraph %s (engine: %s).", subgraph->stream_id, subgraph->name.c_str(), engine_name.c_str()); } } @@ -363,12 +364,12 @@ Status NodeStreamUpdatePass::Run(ComputeGraphPtr graph, const vectorGetName().c_str(), node->GetType().c_str(), subgraph->name.c_str(), context.default_stream, engine_name.c_str()); } else if (IsEngineSkip(*subgraph) && node->GetInNodes().empty()) { - GELOGD("Node %s of type %s in subgraph %s doesn't need to assign a stream (engine: %s).", + GELOGD("[Skip][StreamIdAssign]Node %s of type %s in subgraph %s doesn't need (engine: %s).", node->GetName().c_str(), node->GetType().c_str(), subgraph->name.c_str(), engine_name.c_str()); } else { node->GetOpDesc()->SetStreamId(stream_id); - GELOGD("Node %s of type %s in subgraph %s is assigned stream %ld (engine: %s).", node->GetName().c_str(), - node->GetType().c_str(), subgraph->name.c_str(), stream_id, engine_name.c_str()); + GELOGD("[Assign][StreamId]id:%ld for Node %s of type %s in subgraph %s (engine: %s).", stream_id, + node->GetName().c_str(), node->GetType().c_str(), subgraph->name.c_str(), engine_name.c_str()); } } } @@ -397,8 +398,8 @@ int64_t UpdateForSkippedEnginePass::GetSingleInoutStream(const NodePtr &node) co if (stream_ids.size() == 1) { int64_t stream_id = *(stream_ids.begin()); - GELOGI("The stream of all input and output nodes of node %s (type: %s) is %ld.", node->GetName().c_str(), - node->GetType().c_str(), stream_id); + GELOGI("[Get][SingleStreamId]The stream of all input and output nodes of node %s (type: %s) is %ld.", + node->GetName().c_str(), node->GetType().c_str(), stream_id); return stream_id; } @@ -437,8 +438,8 @@ Status UpdateForSkippedEnginePass::Run(ComputeGraphPtr graph, const vectorSetStreamId(inout_stream); - GELOGI("Node %s of type %s reassign to stream %ld from stream %ld.", node->GetName().c_str(), - node->GetType().c_str(), inout_stream, stream_id); + GELOGI("[Reassign][StreamId]%ld for Node %s of type %s from stream %ld.", + inout_stream, node->GetName().c_str(), node->GetType().c_str(), stream_id); } } } diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index 288b7b29..f9921044 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -597,11 +597,13 @@ void BlockMemAssigner::GetOutAndWorkSpaceMem(vector &all_memory_size) { int64_t size = 0; GE_IF_BOOL_EXEC(ge::TensorUtils::GetSize(output_desc, size) != SUCCESS, GELOGI("Get size failed")); GE_IF_BOOL_EXEC(size < 0, - GELOGE(FAILED, "[Check][TensorSize]tensor_size:%ld is invalid, maybe it is unknown shape node, Node_name:%s", - size, node_op_desc->GetName().c_str()); - REPORT_INNER_ERROR("E19999", "tensor_size:%ld is invalid, maybe it is unknown shape node, Node_name:%s", - size, node_op_desc->GetName().c_str()); - return;); + GELOGE(FAILED, "[Check][TensorSize]tensor_size:%ld is invalid, " + "maybe it is unknown shape node, Node_name:%s", + size, node_op_desc->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "tensor_size:%ld is invalid, " + "maybe it is unknown shape node, Node_name:%s", + size, node_op_desc->GetName().c_str()); + return;); batch_all_memory_size[batch_label].emplace_back(size); if (batch_total_size.find(batch_label) == batch_total_size.end()) { batch_total_size[batch_label] = size; @@ -692,23 +694,23 @@ bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t ou auto out_anchor = n->GetOutDataAnchor(out_index); GE_IF_BOOL_EXEC(out_anchor == nullptr, GELOGE(FAILED, "[Check][Anchor]Node[%s] output[%u] anchor is null.", - n->GetName().c_str(), out_index); + n->GetName().c_str(), out_index); REPORT_INNER_ERROR("E19999", "output anchor is null, node_name: %s output_index: %u.", - n->GetName().c_str(), out_index); + n->GetName().c_str(), out_index); return false;); for (auto const &peer_in_anchor : out_anchor->GetPeerInDataAnchors()) { GE_IF_BOOL_EXEC(peer_in_anchor == nullptr, GELOGE(FAILED, "[Check][Anchor]Node[%s] output[%u] peer_in_anchor 0 is null.", - n->GetName().c_str(), out_index); + n->GetName().c_str(), out_index); REPORT_INNER_ERROR("E19999", "output anchor peer is null, node_name: %s output_index: %u.", - n->GetName().c_str(), out_index); + n->GetName().c_str(), out_index); return false;); auto peer_node = peer_in_anchor->GetOwnerNode(); GE_IF_BOOL_EXEC(peer_node == nullptr, GELOGE(FAILED, "[Check][Node]Node[%s] output[%u] peer node is null.", - n->GetName().c_str(), out_index); + n->GetName().c_str(), out_index); REPORT_INNER_ERROR("E19999", "output anchor peer node is null, node_name: %s output_index: %u.", - n->GetName().c_str(), out_index); + n->GetName().c_str(), out_index); return false;); // Get the continuous input type of the node, default is false @@ -716,9 +718,9 @@ bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t ou auto peer_in_node_desc = peer_node->GetOpDesc(); GE_IF_BOOL_EXEC(peer_in_node_desc == nullptr, GELOGE(FAILED, "[Check][OpDesc]Node[%s] output[%u] nodedesc is null.", - n->GetName().c_str(), out_index); + n->GetName().c_str(), out_index); REPORT_INNER_ERROR("E19999", "output anchor peer op_desc is null, node_name:%s output_index:%u.", - n->GetName().c_str(), out_index); + n->GetName().c_str(), out_index); return false;); // If GetBool fail, is_input_continuous is false. @@ -819,7 +821,7 @@ bool BlockMemAssigner::IsContinuousMemoryReuse(const NodePtr &n, const NodePtr & (in_anchor->GetPeerOutAnchor()->GetOwnerNode() == nullptr) || (in_anchor->GetPeerOutAnchor()->GetOwnerNode()->GetOpDesc() == nullptr)) { GELOGE(FAILED, "[Check][OpDesc]Node[%s] output[%u] peer input node desc is null.", - n->GetName().c_str(), out_index); + n->GetName().c_str(), out_index); REPORT_INNER_ERROR("E19999", "get output anchor peer op_desc fail, node_name: %s output_index: %u.", n->GetName().c_str(), out_index); return false; @@ -1105,9 +1107,10 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, OpMemoryType mem_type, const NodePtr &n, uint32_t out_index, const vector &workspace_reuse_flag, const bool is_op_reuse_mem, const bool continuous, int64_t memory_type) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(n == nullptr, - REPORT_INNER_ERROR("E19999", "Input parameter n(type:node_ptr) is null, apply memory failed"); - return nullptr, "[Check][Param]Input parameter n(type:node_ptr) is null."); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + n == nullptr, + REPORT_INNER_ERROR("E19999", "Input parameter n(type:node_ptr) is null, apply memory failed"); + return nullptr, "[Check][Param]Input parameter n(type:node_ptr) is null."); auto node_op_desc = n->GetOpDesc(); GE_IF_BOOL_EXEC(node_op_desc == nullptr, return nullptr); std::string batch_label; @@ -1159,10 +1162,12 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, } auto block = new (std::nothrow) MemoryBlock(block_size, node_op_desc->GetStreamId(), is_reuse_memory, memory_type); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(block == nullptr, - REPORT_INNER_ERROR("E19999", "new a memoryblock object failed. node_name:%s out_index:%u", - n->GetName().c_str(), out_index); - return nullptr, "[New][Object]new MemoryBlock failed, node_name:%s out_index:%u", n->GetName().c_str(), out_index); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + block == nullptr, + REPORT_INNER_ERROR("E19999", "new a memoryblock object failed. node_name:%s out_index:%u", + n->GetName().c_str(), out_index); + return nullptr, + "[New][Object]new MemoryBlock failed, node_name:%s out_index:%u", n->GetName().c_str(), out_index); // Data and netoutput need zero copy block block->is_zero_copy_ = IsZeroCopyBlock(n, continuous); @@ -1221,13 +1226,15 @@ void BlockMemAssigner::ContinuousOutRefCheck(bool &isAllOutputRef, bool &isOutpu Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vector &ranges, const bool is_op_reuse_mem) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(n == nullptr, - REPORT_INNER_ERROR("E19999", "Input parameter n(type:node_ptr) is null"); - return INTERNAL_ERROR, "[check][param]Input parameter n(type:NodePtr) is null."); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + n == nullptr, + REPORT_INNER_ERROR("E19999", "Input parameter n(type:node_ptr) is null"); + return INTERNAL_ERROR, "[check][param]Input parameter n(type:NodePtr) is null."); auto node_op_desc = n->GetOpDesc(); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(node_op_desc == nullptr, - REPORT_INNER_ERROR("E19999", "Input parameter n(type:OpDescPtr) is null"); - return INTERNAL_ERROR, "[Check][Param]Input parameter n(type:OpDescPtr) is null"); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + node_op_desc == nullptr, + REPORT_INNER_ERROR("E19999", "Input parameter n(type:OpDescPtr) is null"); + return INTERNAL_ERROR, "[Check][Param]Input parameter n(type:OpDescPtr) is null"); // continuous output support ref only when all output ref input bool isAllOutputRef = true; @@ -1242,7 +1249,7 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vectorGetName().c_str()); + n->GetName().c_str()); GELOGE(INTERNAL_ERROR, "[Check][OutRefStatus]continuous output node ref part input, not support, node_name:%s", n->GetName().c_str()); return INTERNAL_ERROR; @@ -1255,7 +1262,7 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vectorGetOutputDescPtr(index); if (output_op_desc == nullptr) { REPORT_INNER_ERROR("E19999", "get output_desc failed, node_name:%s, output_index:%u", - n->GetName().c_str(), index); + n->GetName().c_str(), index); GELOGE(INTERNAL_ERROR, "[Get][OutputDesc]node_name:%s, output_index:%u", n->GetName().c_str(), index); return INTERNAL_ERROR; } @@ -1268,7 +1275,7 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vectorGetName().c_str(), index); + n->GetName().c_str(), index); GELOGE(INTERNAL_ERROR, "[Get][TensorSize]node_name:%s, output_index:%u", n->GetName().c_str(), index); return INTERNAL_ERROR; } @@ -1310,7 +1317,7 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vectorref_count_); } else { REPORT_CALL_ERROR("E19999", "apply continuousMemory failed, node_name:%s, total_size:%ld", - n->GetName().c_str(), total_size); + n->GetName().c_str(), total_size); GELOGE(INTERNAL_ERROR, "[Apply][ContinuousMemory]node_name:%s, total_size:%ld", n->GetName().c_str(), total_size); return INTERNAL_ERROR; } @@ -1319,26 +1326,33 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vector &ranges, const bool is_op_reuse_mem, const bool continuous) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(n == nullptr, - REPORT_INNER_ERROR("E19999", "Input parameter n(type:NodePtr) is null"); - return nullptr, "[Check][Param]Input parameter n(type:NodePtr) is null"); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + n == nullptr, + REPORT_INNER_ERROR("E19999", "Input parameter n(type:NodePtr) is null"); + return nullptr, "[Check][Param]Input parameter n(type:NodePtr) is null"); auto node_op_desc = n->GetOpDesc(); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(node_op_desc == nullptr, - REPORT_INNER_ERROR("E19999", "Input parameter n(type:OpDescPtr) is null"); - return nullptr, "[Check][Param]Input parameter n(type:OpDescPtr) is null"); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + node_op_desc == nullptr, + REPORT_INNER_ERROR("E19999", "Input parameter n(type:OpDescPtr) is null"); + return nullptr, "[Check][Param]Input parameter n(type:OpDescPtr) is null"); MemoryBlock *block = nullptr; NodeIndexIO node_index_io(n, index, kOut); int64_t size = 0; auto output_op_desc = node_op_desc->GetOutputDescPtr(index); - GE_IF_BOOL_EXEC(output_op_desc == nullptr, - REPORT_INNER_ERROR("E19999", "get output_desc failed, node_name:%s, output_index:%u", n->GetName().c_str(), index); - GELOGE(FAILED, "[Get][OutputDesc]node_name:%s, output_index:%u", n->GetName().c_str(), index); - return nullptr); + GE_IF_BOOL_EXEC( + output_op_desc == nullptr, + REPORT_INNER_ERROR("E19999", "get output_desc failed, node_name:%s, output_index:%u", + n->GetName().c_str(), index); + GELOGE(FAILED, "[Get][OutputDesc]node_name:%s, output_index:%u", n->GetName().c_str(), index); + return nullptr); GE_IF_BOOL_EXEC(ge::TensorUtils::GetSize(*output_op_desc, size) != SUCCESS, GELOGI("Get size failed")); size_t no_align_size = 0; - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetNoAlignSize(*node_op_desc, index, no_align_size) != SUCCESS, - REPORT_CALL_ERROR("E19999", "Get no align size failed, node_name:%s, output_index:%u", n->GetName().c_str(), index); - return nullptr, "[Get][TensorSize]Get no align size, node_name:%s, output_index:%u", n->GetName().c_str(), index); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + GetNoAlignSize(*node_op_desc, index, no_align_size) != SUCCESS, + REPORT_CALL_ERROR("E19999", "Get no align size failed, node_name:%s, output_index:%u", + n->GetName().c_str(), index); + return nullptr, + "[Get][TensorSize]Get no align size, node_name:%s, output_index:%u", n->GetName().c_str(), index); std::string symbol; bool reuse_input = false; @@ -1346,9 +1360,9 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, block = symbol_blocks_[symbol]; GE_IF_BOOL_EXEC(block == nullptr, REPORT_INNER_ERROR("E19999", "get ref block failed, node_name:%s, symbol:%s", - node_op_desc->GetName().c_str(), node_index_io.ToString().c_str()); + node_op_desc->GetName().c_str(), node_index_io.ToString().c_str()); GELOGE(FAILED, "[Get][RefBlock]node_name:%s, symbol:%s", - node_op_desc->GetName().c_str(), node_index_io.ToString().c_str()); + node_op_desc->GetName().c_str(), node_index_io.ToString().c_str()); return nullptr); // reduce old size size_t align_size = block->Size(); @@ -1392,24 +1406,28 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, vector workspace_reuse_flag; block = ApplyMemory(block_size, size, no_align_size, kOutput, n, index, workspace_reuse_flag, is_op_reuse_mem, continuous, memory_type); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(block == nullptr, - REPORT_CALL_ERROR("E19999", "apply out Memory failed, node_name:%s, block_size:%ld, out_index:%u", - n->GetName().c_str(), block_size, index); - return nullptr, "[Apply][Memory]node_name:%s, block_size:%ld, out_index:%u", + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + block == nullptr, + REPORT_CALL_ERROR("E19999", "apply out Memory failed, node_name:%s, block_size:%ld, out_index:%u", + n->GetName().c_str(), block_size, index); + return nullptr, + "[Apply][Memory]node_name:%s, block_size:%ld, out_index:%u", n->GetName().c_str(), block_size, index); } int out_count = 0; - GE_IF_BOOL_EXEC(index >= n->GetAllOutDataAnchors().size(), - REPORT_INNER_ERROR("E19999", "out index:%u exceed out_size:%lu, node_name:%s", - index, n->GetAllOutDataAnchors().size(), n->GetName().c_str()); - GELOGE(FAILED, "[Check][OutIndex]index:%u exceed out_size:%lu, node_name:%s", - index, n->GetAllOutDataAnchors().size(), n->GetName().c_str()); - return nullptr); + GE_IF_BOOL_EXEC( + index >= n->GetAllOutDataAnchors().size(), + REPORT_INNER_ERROR("E19999", "out index:%u exceed out_size:%lu, node_name:%s", + index, n->GetAllOutDataAnchors().size(), n->GetName().c_str()); + GELOGE(FAILED, "[Check][OutIndex]index:%u exceed out_size:%lu, node_name:%s", + index, n->GetAllOutDataAnchors().size(), n->GetName().c_str()); + return nullptr); auto out_data_anchor = n->GetOutDataAnchor(index); - GE_IF_BOOL_EXEC(out_data_anchor == nullptr, - REPORT_INNER_ERROR("E19999", "out anchor is null, index:%u, node_name:%s", index, n->GetName().c_str()); - GELOGE(FAILED, "[Check][OutAnchor]is null, index:%u, node_name:%s", index, n->GetName().c_str()); - return nullptr); + GE_IF_BOOL_EXEC( + out_data_anchor == nullptr, + REPORT_INNER_ERROR("E19999", "out anchor is null, index:%u, node_name:%s", index, n->GetName().c_str()); + GELOGE(FAILED, "[Check][OutAnchor]is null, index:%u, node_name:%s", index, n->GetName().c_str()); + return nullptr); for (const auto &in_anchor : out_data_anchor->GetPeerInDataAnchors()) { auto owner_node = in_anchor->GetOwnerNode(); auto op_desc = owner_node->GetOpDesc(); @@ -1616,12 +1634,13 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector op_desc->GetOutputsSize(), memorys_type.size()); if (has_mem_type_attr && (memorys_type.size() != op_desc->GetOutputsSize())) { REPORT_INNER_ERROR("E19999", "Attr[%s] size:%zu not equal to node output size:%zu, node_name:%s", - ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), memorys_type.size(), - op_desc->GetOutputsSize(), op_desc->GetName().c_str()); - GELOGE(INTERNAL_ERROR, - "[Check][MemTypeAttr]Attr %s size:%zu not equal to node output size:%zu, node_name:%s", - ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), memorys_type.size(), - op_desc->GetOutputsSize(), op_desc->GetName().c_str()); + ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), memorys_type.size(), + op_desc->GetOutputsSize(), op_desc->GetName().c_str()); + GELOGE( + INTERNAL_ERROR, + "[Check][MemTypeAttr]Attr %s size:%zu not equal to node output size:%zu, node_name:%s", + ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), memorys_type.size(), + op_desc->GetOutputsSize(), op_desc->GetName().c_str()); return INTERNAL_ERROR; } @@ -1748,9 +1767,11 @@ void BlockMemAssigner::AssignMemoryWithReuse(vector &ranges) { if (has_tvm_workspace_mem_type_attr && (temp.size() != tvm_workspace_memory_type.size())) { REPORT_INNER_ERROR("E19999", "Attr[%s]size:%zu is not equal to workspace size:%zu, node_name:%s", - TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), tvm_workspace_memory_type.size(), temp.size(), n->GetName().c_str()); + TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), tvm_workspace_memory_type.size(), + temp.size(), n->GetName().c_str()); GELOGE(INTERNAL_ERROR, "[Check][Attr]Attr %s size:%zu is not equal to workspace size:%zu, node_name:%s", - TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), tvm_workspace_memory_type.size(), temp.size(), n->GetName().c_str()); + TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), tvm_workspace_memory_type.size(), + temp.size(), n->GetName().c_str()); return; } for (size_t i = 0; i < temp.size(); i++) { @@ -2160,10 +2181,11 @@ bool BlockMemAssigner::GetWorkSpaceMemoryType(const NodePtr &node, size_t index, ge::AttrUtils::GetListInt(op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, workspace_memory_type); if (has_workspace_mem_type_attr && (workspace_memory_type.size() <= index)) { REPORT_INNER_ERROR("E19999", "get workspace mem_type failed, " - "index %zu invalid, bigger than attr %s size:%zu, node_name:%s", - index, TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), workspace_memory_type.size(), node->GetName().c_str()); + "index %zu invalid, bigger than attr %s size:%zu, node_name:%s", + index, TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), + workspace_memory_type.size(), node->GetName().c_str()); GELOGE(INTERNAL_ERROR, "[Get][WorkspaceMemType]index %zu invalid, bigger than attr %s size:%zu, node_name:%s", - index, TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), workspace_memory_type.size(), node->GetName().c_str()); + index, TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), workspace_memory_type.size(), node->GetName().c_str()); return false; } memory_type = has_workspace_mem_type_attr ? workspace_memory_type[index] : RT_MEMORY_HBM; diff --git a/ge/plugin/engine/CMakeLists.txt b/ge/plugin/engine/CMakeLists.txt index e5736b51..3aace4ac 100644 --- a/ge/plugin/engine/CMakeLists.txt +++ b/ge/plugin/engine/CMakeLists.txt @@ -41,6 +41,7 @@ target_link_options(engine PRIVATE target_link_libraries(engine PRIVATE $ -Wl,--no-as-needed + c_sec slog -Wl,--as-needed -lrt diff --git a/tests/ut/ge/common/format_transfer_fractal_nz_unittest.cc b/tests/ut/ge/common/format_transfer_fractal_nz_unittest.cc index 5bbc5776..02f8251a 100644 --- a/tests/ut/ge/common/format_transfer_fractal_nz_unittest.cc +++ b/tests/ut/ge/common/format_transfer_fractal_nz_unittest.cc @@ -9136,23 +9136,23 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_src_data_type2) { EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } -// TEST_F(UtestFormatTransferNdFractNz, invalid_src_data_type3) { -// uint16_t data[1 * 1 * 1 * 16 * 16] = {0}; -// TransArgs args{reinterpret_cast(data), -// FORMAT_FRACTAL_NZ, -// FORMAT_NHWC, -// {1, 1, 1, 16, 16}, -// { -// 1, -// 1, -// 4, -// 4, -// }, -// DT_VARIANT}; -// TransResult result; -// FormatTransferFractalNzND transfer; -// EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); -// } +TEST_F(UtestFormatTransferNdFractNz, invalid_src_data_type3) { + uint16_t data[1 * 1 * 1 * 16 * 16] = {0}; + TransArgs args{reinterpret_cast(data), + FORMAT_FRACTAL_NZ, + FORMAT_NHWC, + {1, 1, 1, 16, 16}, + { + 1, + 1, + 4, + 4, + }, + DT_STRING}; + TransResult result; + FormatTransferFractalNzND transfer; + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); +} TEST_F(UtestFormatTransferNdFractNz, invalid_dst_format2) { uint16_t data[1 * 1 * 1 * 1 * 16 * 16] = {0}; diff --git a/tests/ut/ge/common/format_transfer_nhwc_fractalz_unittest.cc b/tests/ut/ge/common/format_transfer_nhwc_fractalz_unittest.cc index b2cfe2db..7431440b 100644 --- a/tests/ut/ge/common/format_transfer_nhwc_fractalz_unittest.cc +++ b/tests/ut/ge/common/format_transfer_nhwc_fractalz_unittest.cc @@ -5354,14 +5354,14 @@ TEST_F(UtestFormatTransferNhwcFz, build_transfer_uint8) { EXPECT_NE(transfer, nullptr); } -// TEST_F(UtestFormatTransferNhwcFz, invalid_data_type) { -// uint16_t data[1 * 4 * 4 * 1] = {0}; -// TransArgs args{ -// reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_NZ, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_VARIANT}; -// FormatTransferFractalZ transfer; -// EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), -// ACL_ERROR_GE_DATATYPE_INVALID); -// } +TEST_F(UtestFormatTransferNhwcFz, invalid_data_type) { + uint16_t data[1 * 4 * 4 * 1] = {0}; + TransArgs args{ + reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_NZ, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_STRING}; + FormatTransferFractalZ transfer; + EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), + ACL_ERROR_GE_DATATYPE_INVALID); +} TEST_F(UtestFormatTransferNhwcFz, invalid_data_format) { uint16_t data[1 * 4 * 4 * 1] = {0}; diff --git a/tests/ut/ge/common/format_transfer_unittest.cc b/tests/ut/ge/common/format_transfer_unittest.cc index 1a56d2f9..73b7703d 100644 --- a/tests/ut/ge/common/format_transfer_unittest.cc +++ b/tests/ut/ge/common/format_transfer_unittest.cc @@ -52,34 +52,34 @@ TEST_F(UtestFormatTransfer, build_unsupported_transfer) { EXPECT_EQ(transfer2, nullptr); } -// TEST_F(UtestFormatTransfer, get_size_by_data_type) { -// EXPECT_EQ(GetSizeByDataType(DT_FLOAT), 4); -// EXPECT_EQ(GetSizeByDataType(DT_FLOAT16), 2); -// EXPECT_EQ(GetSizeByDataType(DT_INT8), 1); -// EXPECT_EQ(GetSizeByDataType(DT_INT16), 2); -// EXPECT_EQ(GetSizeByDataType(DT_UINT16), 2); -// EXPECT_EQ(GetSizeByDataType(DT_UINT8), 1); -// EXPECT_EQ(GetSizeByDataType(DT_INT32), 4); -// EXPECT_EQ(GetSizeByDataType(DT_INT64), 8); -// EXPECT_EQ(GetSizeByDataType(DT_UINT32), 4); -// EXPECT_EQ(GetSizeByDataType(DT_UINT64), 8); -// EXPECT_EQ(GetSizeByDataType(DT_BOOL), 1); -// EXPECT_EQ(GetSizeByDataType(DT_DOUBLE), 8); -// EXPECT_EQ(GetSizeByDataType(DT_STRING), -1); -// EXPECT_EQ(GetSizeByDataType(DT_DUAL_SUB_INT8), 1); -// EXPECT_EQ(GetSizeByDataType(DT_DUAL_SUB_UINT8), 1); -// EXPECT_EQ(GetSizeByDataType(DT_COMPLEX64), 8); -// EXPECT_EQ(GetSizeByDataType(DT_COMPLEX128), 16); -// EXPECT_EQ(GetSizeByDataType(DT_QINT8), 1); -// EXPECT_EQ(GetSizeByDataType(DT_QINT16), 2); -// EXPECT_EQ(GetSizeByDataType(DT_QINT32), 4); -// EXPECT_EQ(GetSizeByDataType(DT_QUINT8), 1); -// EXPECT_EQ(GetSizeByDataType(DT_QUINT16), 2); -// EXPECT_EQ(GetSizeByDataType(DT_RESOURCE), -1); -// EXPECT_EQ(GetSizeByDataType(DT_STRING_REF), -1); -// EXPECT_EQ(GetSizeByDataType(DT_DUAL), 5); -// EXPECT_EQ(GetSizeByDataType(DT_UNDEFINED), -1); -// EXPECT_EQ(DT_UNDEFINED, 27); -// } +TEST_F(UtestFormatTransfer, get_size_by_data_type) { + EXPECT_EQ(GetSizeByDataType(DT_FLOAT), 4); + EXPECT_EQ(GetSizeByDataType(DT_FLOAT16), 2); + EXPECT_EQ(GetSizeByDataType(DT_INT8), 1); + EXPECT_EQ(GetSizeByDataType(DT_INT16), 2); + EXPECT_EQ(GetSizeByDataType(DT_UINT16), 2); + EXPECT_EQ(GetSizeByDataType(DT_UINT8), 1); + EXPECT_EQ(GetSizeByDataType(DT_INT32), 4); + EXPECT_EQ(GetSizeByDataType(DT_INT64), 8); + EXPECT_EQ(GetSizeByDataType(DT_UINT32), 4); + EXPECT_EQ(GetSizeByDataType(DT_UINT64), 8); + EXPECT_EQ(GetSizeByDataType(DT_BOOL), 1); + EXPECT_EQ(GetSizeByDataType(DT_DOUBLE), 8); + EXPECT_EQ(GetSizeByDataType(DT_STRING), -1); + EXPECT_EQ(GetSizeByDataType(DT_DUAL_SUB_INT8), 1); + EXPECT_EQ(GetSizeByDataType(DT_DUAL_SUB_UINT8), 1); + EXPECT_EQ(GetSizeByDataType(DT_COMPLEX64), 8); + EXPECT_EQ(GetSizeByDataType(DT_COMPLEX128), 16); + EXPECT_EQ(GetSizeByDataType(DT_QINT8), 1); + EXPECT_EQ(GetSizeByDataType(DT_QINT16), 2); + EXPECT_EQ(GetSizeByDataType(DT_QINT32), 4); + EXPECT_EQ(GetSizeByDataType(DT_QUINT8), 1); + EXPECT_EQ(GetSizeByDataType(DT_QUINT16), 2); + EXPECT_EQ(GetSizeByDataType(DT_RESOURCE), 8); + EXPECT_EQ(GetSizeByDataType(DT_STRING_REF), -1); + EXPECT_EQ(GetSizeByDataType(DT_DUAL), 5); + EXPECT_EQ(GetSizeByDataType(DT_UNDEFINED), -1); + EXPECT_EQ(DT_UNDEFINED, 28); +} } // namespace formats } // namespace ge