已关闭
【PR】: 修复st编译warning #26
黄桂军创建于 2025年12月29日关闭于 3月28日
【PR】: 修复st编译warning #26
已关闭
共 37 个文件变更+243-234
| @@ -18,18 +18,6 @@ namespace py = pybind11; | |||
| 18 | namespace llm { | 18 | namespace llm { |
| 19 | std::unique_ptr<LLMDataDist> LLMDataDistWrapper::llm_data_dist; | 19 | std::unique_ptr<LLMDataDist> LLMDataDistWrapper::llm_data_dist; |
| 20 | 20 | ||
| 21 | -namespace { | ||
| 22 | -ge::Status CollectTensors(const std::map<int32_t, std::vector<uintptr_t>> &device_id_to_inputs, | ||
| 23 | - std::map<int32_t, std::vector<ge::Tensor>> &device_id_to_input_tensors) { | ||
| 24 | - for (const auto &device_id_and_tensor_ids : device_id_to_inputs) { | ||
| 25 | - std::vector<ge::Tensor> tensors; | ||
| 26 | - LLM_CHK_STATUS_RET(LLMTensor::TensorIdsToTensors(device_id_and_tensor_ids.second, tensors)); | ||
| 27 | - device_id_to_input_tensors.emplace(device_id_and_tensor_ids.first, std::move(tensors)); | ||
| 28 | - } | ||
| 29 | - return ge::SUCCESS; | ||
| 30 | -} | ||
| 31 | -} // namespace | ||
| 32 | - | ||
| 33 | CopyCacheParam LLMDataDistWrapper::UnpackCopyCacheParam(CopyCacheParamTuple cache_param_tuple) { | 21 | CopyCacheParam LLMDataDistWrapper::UnpackCopyCacheParam(CopyCacheParamTuple cache_param_tuple) { |
| 34 | constexpr size_t kIndexDstCacheId = 0; | 22 | constexpr size_t kIndexDstCacheId = 0; |
| 35 | constexpr size_t kIndexSrcCacheId = 1; | 23 | constexpr size_t kIndexSrcCacheId = 1; |
| @@ -43,7 +43,7 @@ std::vector<std::unique_ptr<ge::TmpBufDesc>> CalcGatherTmpSizeV2(const ge::AscNo | |||
| 43 | AscNodeInputs node_inputs = node.inputs; | 43 | AscNodeInputs node_inputs = node.inputs; |
| 44 | AscNodeOutputs node_outputs = node.outputs; | 44 | AscNodeOutputs node_outputs = node.outputs; |
| 45 | Expression param_size = Symbol(ONE); | 45 | Expression param_size = Symbol(ONE); |
| 46 | - for(int i = 0;i < node_inputs[0].attr.repeats.size();i++) { | 46 | + for(size_t i = 0U; i < node_inputs[0].attr.repeats.size(); i++) { |
| 47 | param_size = sym::Mul(param_size, node_inputs[0].attr.repeats[i]); | 47 | param_size = sym::Mul(param_size, node_inputs[0].attr.repeats[i]); |
| 48 | } | 48 | } |
| 49 | GE_CHK_BOOL_RET_SPECIAL_STATUS(node_inputs.Size() < TWO, tmpBufDescs, "node.inputs.Size less than TWO"); | 49 | GE_CHK_BOOL_RET_SPECIAL_STATUS(node_inputs.Size() < TWO, tmpBufDescs, "node.inputs.Size less than TWO"); |
| @@ -68,7 +68,7 @@ std::vector<std::unique_ptr<ge::TmpBufDesc>> CalcGatherTmpSizeV2(const ge::AscNo | |||
| 68 | indices_add = Symbol(INDICES_ADD_INT64); | 68 | indices_add = Symbol(INDICES_ADD_INT64); |
| 69 | critical_point = Symbol(CRITICAL_POINT_INT64); | 69 | critical_point = Symbol(CRITICAL_POINT_INT64); |
| 70 | } | 70 | } |
| 71 | - for(int i = 0;i < node_inputs[1].attr.repeats.size();i++){ | 71 | + for(size_t i = 0U; i < node_inputs[1].attr.repeats.size(); i++){ |
| 72 | indicesSize = sym::Mul(indicesSize, node_inputs[1].attr.repeats[i]); | 72 | indicesSize = sym::Mul(indicesSize, node_inputs[1].attr.repeats[i]); |
| 73 | } | 73 | } |
| 74 | Expression indices_tmp = sym::Div(indicesSize, indices_div); | 74 | Expression indices_tmp = sym::Div(indicesSize, indices_div); |
| @@ -1007,18 +1007,20 @@ Status AscGraphAxisMapping::ProcessSubGraphVerticalMapInfo(const NodePtr &node1, | |||
| 1007 | return FAILED; | 1007 | return FAILED; |
| 1008 | } | 1008 | } |
| 1009 | } else { | 1009 | } else { |
| 1010 | - // node1 node1 node1 | 1010 | + /* |
| 1011 | - // /\ /\ | | 1011 | + * node1 node1 node1 |
| 1012 | - // / \ / \ | | 1012 | + * /\ /\ | |
| 1013 | - // 原图 node2 node3 -> 场景1: node2 \ 场景2: FusedAscBackend | 1013 | + * / \ / \ | |
| 1014 | - // \ / \ \ | 1014 | + * 原图 node2 node3 -> 场景1: node2 \ 场景2: FusedAscBackend |
| 1015 | - // concat FusedAscendBackend | 1015 | + * \ / \ \ |
| 1016 | - // 上面原图里node1的输出多引用,连接了node2和node3,此时有两种融合场景: | 1016 | + * concat FusedAscendBackend |
| 1017 | - // 场景1:node3和concat融合,然后node2不能和concat融合,此时需要判断node1和Fused节点是否能融合。如果node1的输出是多引用,同时Fused | 1017 | + * 上面原图里node1的输出多引用,连接了node2和node3,此时有两种融合场景: |
| 1018 | - // 节点中与node1连接的节点中包含view op,那么node1和Fused节点不能融合。 | 1018 | + * 场景1:node3和concat融合,然后node2不能和concat融合,此时需要判断node1和Fused节点是否能融合。如果node1的输出是多引用,同时Fused |
| 1019 | - // 场景2:node3和node2与concat节点融合了,最后会判断node1和Fused节点是否能融合,这个时候node1和Fused节点只有一条边,fuse_info中没有 | 1019 | + * 节点中与node1连接的节点中包含view op,那么node1和Fused节点不能融合。 |
| 1020 | - // 多引用的信息。这个时候不能只用fuse_info.HasMulReference()来判断,还需要判断Fused节点中与node1连接的data节点后面是否有多个节点。 | 1020 | + * 场景2:node3和node2与concat节点融合了,最后会判断node1和Fused节点是否能融合,这个时候node1和Fused节点只有一条边,fuse_info中没有 |
| 1021 | - // 如果后面有多个节点(> 1U),同时对应节点中也包含view op,那么node1和Fused节点不能融合。 | 1021 | + * 多引用的信息。这个时候不能只用fuse_info.HasMulReference()来判断,还需要判断Fused节点中与node1连接的data节点后面是否有多个节点。 |
| 1022 | + * 如果后面有多个节点(> 1U),同时对应节点中也包含view op,那么node1和Fused节点不能融合。 | ||
| 1023 | + */ | ||
| 1022 | bool has_mul_reference = fuse_info.HasMulReference(); | 1024 | bool has_mul_reference = fuse_info.HasMulReference(); |
| 1023 | auto asc_node = node2; | 1025 | auto asc_node = node2; |
| 1024 | auto index = subgraph_link.second; | 1026 | auto index = subgraph_link.second; |
| @@ -252,7 +252,6 @@ Status BackendUtils::FusedBackSteppingViewOpBroadcast(TensorAttrInfo &temp_graph | |||
| 252 | auto &broadcast_info = attr_info.broadcast_info; | 252 | auto &broadcast_info = attr_info.broadcast_info; |
| 253 | const auto &load_axis = temp_load_attr.axis; | 253 | const auto &load_axis = temp_load_attr.axis; |
| 254 | const auto &load_repeats = temp_load_attr.repeats; | 254 | const auto &load_repeats = temp_load_attr.repeats; |
| 255 | - const auto &load_strides = temp_load_attr.strides; | ||
| 256 | 255 | ||
| 257 | GE_ASSERT_TRUE(temp_graph_attr.axis.size() <= load_repeats.size()); | 256 | GE_ASSERT_TRUE(temp_graph_attr.axis.size() <= load_repeats.size()); |
| 258 | for (auto index = 0U; index < load_repeats.size(); index++) { | 257 | for (auto index = 0U; index < load_repeats.size(); index++) { |
| @@ -22,8 +22,8 @@ bool SplitFusionStrategy::CanFuse(const NodePtr &node1, const NodePtr &node2) { | |||
| 22 | const auto attr2 = BackendUtils::GetNodeAutoFuseAttr(node2); | 22 | const auto attr2 = BackendUtils::GetNodeAutoFuseAttr(node2); |
| 23 | GE_ASSERT_NOTNULL(attr2); | 23 | GE_ASSERT_NOTNULL(attr2); |
| 24 | 24 | ||
| 25 | - if (attr1->HasFuseType(loop::FuseType::kSplit) && attr2->HasFuseType(loop::FuseType::kReduction) | 25 | + if ((attr1->HasFuseType(loop::FuseType::kSplit) && attr2->HasFuseType(loop::FuseType::kReduction)) |
| 26 | - || attr1->HasFuseType(loop::FuseType::kReduction) && attr2->HasFuseType(loop::FuseType::kSplit)) { | 26 | + || (attr1->HasFuseType(loop::FuseType::kReduction) && attr2->HasFuseType(loop::FuseType::kSplit))) { |
| 27 | GELOGI( | 27 | GELOGI( |
| 28 | "node1 %s(%s) and node2 %s(%s) can not fuse, the reason is [%s][split cannot fuse reduction]", node1->GetNamePtr(), node1->GetType().c_str(), | 28 | "node1 %s(%s) and node2 %s(%s) can not fuse, the reason is [%s][split cannot fuse reduction]", node1->GetNamePtr(), node1->GetType().c_str(), |
| 29 | node2->GetNamePtr(), node2->GetType().c_str(), | 29 | node2->GetNamePtr(), node2->GetType().c_str(), |
| @@ -118,7 +118,7 @@ graphStatus AscIrLowerer::Lowering(const ComputeGraphPtr &graph) { | |||
| 118 | graphs.insert(graphs.begin(), graph); | 118 | graphs.insert(graphs.begin(), graph); |
| 119 | } | 119 | } |
| 120 | for (const auto &subgraph : graphs) { | 120 | for (const auto &subgraph : graphs) { |
| 121 | - GE_ASSERT_GRAPH_SUCCESS(RemoveDirectNodeUnusedEdges(graph)); | 121 | + GE_ASSERT_GRAPH_SUCCESS(RemoveDirectNodeUnusedEdges(subgraph)); |
| 122 | } | 122 | } |
| 123 | do_lowered_ = true; | 123 | do_lowered_ = true; |
| 124 | return GRAPH_SUCCESS; | 124 | return GRAPH_SUCCESS; |
| @@ -741,8 +741,8 @@ std::vector<LoopVar> StoreSplit(const std::vector<OutDataAnchorPtr> &outputs, co | |||
| 741 | } | 741 | } |
| 742 | output_dims.emplace_back(outputx_dims); | 742 | output_dims.emplace_back(outputx_dims); |
| 743 | } | 743 | } |
| 744 | - char soc_version[128] = {}; | 744 | + char soc_version[128U] = {}; |
| 745 | - auto res = rtGetSocVersion(soc_version, 128U); | 745 | + (void)rtGetSocVersion(soc_version, 128U); |
| 746 | GELOGI("soc_version: %s", soc_version); | 746 | GELOGI("soc_version: %s", soc_version); |
| 747 | size_t idx = 0U; | 747 | size_t idx = 0U; |
| 748 | std::vector<LoopVar> ret; | 748 | std::vector<LoopVar> ret; |
| @@ -282,17 +282,13 @@ std::vector<loop::KernelBox> GetRealizedKernelBoxes(const ge::NodePtr &node, con | |||
| 282 | } | 282 | } |
| 283 | return realized_kernel_boxes; | 283 | return realized_kernel_boxes; |
| 284 | } | 284 | } |
| 285 | - // view op also lowering to ascbc | ||
| 286 | - for (auto &kernel_box : realized_kernel_boxes) { | ||
| 287 | - return realized_kernel_boxes; | ||
| 288 | - } | ||
| 289 | 285 | ||
| 290 | GELOGI("All kernel box of node %s is too small:", node->GetName().c_str()); | 286 | GELOGI("All kernel box of node %s is too small:", node->GetName().c_str()); |
| 291 | for (auto &kernel_box : realized_kernel_boxes) { | 287 | for (auto &kernel_box : realized_kernel_boxes) { |
| 292 | GELOGI(" kernel box %s num ascend ir nodes %zu < %zu", kernel_box.Name().c_str(), | 288 | GELOGI(" kernel box %s num ascend ir nodes %zu < %zu", kernel_box.Name().c_str(), |
| 293 | kernel_box.GetAscendIrNodes().size(), config.min_ascend_ir_nodes); | 289 | kernel_box.GetAscendIrNodes().size(), config.min_ascend_ir_nodes); |
| 294 | } | 290 | } |
| 295 | - return {}; | 291 | + return realized_kernel_boxes; |
| 296 | } | 292 | } |
| 297 | 293 | ||
| 298 | graphStatus MoveControlEdges(const NodePtr &src, const NodePtr &dst) { | 294 | graphStatus MoveControlEdges(const NodePtr &src, const NodePtr &dst) { |
| @@ -701,7 +701,6 @@ graphStatus LowerGather(const NodePtr &node) { | |||
| 701 | node->GetNamePtr()); | 701 | node->GetNamePtr()); |
| 702 | GE_WARN_ASSERT(batch_dims == 0, "Skip lowering node %s, as: Batch dims is not 0", node->GetNamePtr()); | 702 | GE_WARN_ASSERT(batch_dims == 0, "Skip lowering node %s, as: Batch dims is not 0", node->GetNamePtr()); |
| 703 | std::vector<Expression> dims; | 703 | std::vector<Expression> dims; |
| 704 | - auto indices = node->GetInDataAnchor(1)->GetPeerOutAnchor().get(); | ||
| 705 | for (auto &anchor : node->GetAllInDataAnchors()) { | 704 | for (auto &anchor : node->GetAllInDataAnchors()) { |
| 706 | if (anchor == nullptr || anchor->GetPeerOutAnchor() == nullptr) { | 705 | if (anchor == nullptr || anchor->GetPeerOutAnchor() == nullptr) { |
| 707 | continue; | 706 | continue; |
| @@ -47,10 +47,6 @@ bool IsUltraLowToLowPrecision(DataType peer_output_dtype, DataType output_dtype) | |||
| 47 | return IsUltraLowPrecisionDataType(peer_output_dtype) && IsLowPrecisionDataType(output_dtype); | 47 | return IsUltraLowPrecisionDataType(peer_output_dtype) && IsLowPrecisionDataType(output_dtype); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | -bool IsLowToUltraLowPrecision(DataType peer_output_dtype, DataType output_dtype) { | ||
| 51 | - return IsLowPrecisionDataType(peer_output_dtype) && IsUltraLowPrecisionDataType(output_dtype); | ||
| 52 | -} | ||
| 53 | - | ||
| 54 | bool IsFloatToUltraLowPrecision(DataType peer_output_dtype, DataType output_dtype) { | 50 | bool IsFloatToUltraLowPrecision(DataType peer_output_dtype, DataType output_dtype) { |
| 55 | return IsFloatDataType(peer_output_dtype) && IsUltraLowPrecisionDataType(output_dtype); | 51 | return IsFloatDataType(peer_output_dtype) && IsUltraLowPrecisionDataType(output_dtype); |
| 56 | } | 52 | } |
| @@ -56,31 +56,31 @@ bool IsTransOp(const NodePtr &node) { | |||
| 56 | node->GetType() == RESHAPE || node->GetType() == TRANSDATA; | 56 | node->GetType() == RESHAPE || node->GetType() == TRANSDATA; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | -std::unordered_map<std::string, NodeType> kNodeTypeMap = { | 59 | +std::unordered_map<std::string, LinkNodeType> kNodeTypeMap = { |
| 60 | - {NETOUTPUT, NodeType::kNetOutput}, | 60 | + {NETOUTPUT, LinkNodeType::kNetOutput}, |
| 61 | - {DATA, NodeType::kData}, | 61 | + {DATA, LinkNodeType::kData}, |
| 62 | - {TRANSDATA, NodeType::kTransdata}, | 62 | + {TRANSDATA, LinkNodeType::kTransdata}, |
| 63 | - {CAST, NodeType::kCast} | 63 | + {CAST, LinkNodeType::kCast} |
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| 66 | -NodeType GetNodeType(const NodePtr &node) { | 66 | +LinkNodeType GetNodeType(const NodePtr &node) { |
| 67 | const auto type = node->GetType(); | 67 | const auto type = node->GetType(); |
| 68 | const auto iter = kNodeTypeMap.find(type); | 68 | const auto iter = kNodeTypeMap.find(type); |
| 69 | if (iter != kNodeTypeMap.end()) { | 69 | if (iter != kNodeTypeMap.end()) { |
| 70 | return iter->second; | 70 | return iter->second; |
| 71 | } | 71 | } |
| 72 | if (!node->GetOpDescBarePtr()->GetSubgraphInstanceNames().empty()) { | 72 | if (!node->GetOpDescBarePtr()->GetSubgraphInstanceNames().empty()) { |
| 73 | - return NodeType::kWrapperNode; | 73 | + return LinkNodeType::kWrapperNode; |
| 74 | } | 74 | } |
| 75 | - return NodeType::kOthers; | 75 | + return LinkNodeType::kOthers; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | bool IsWrapperNode(const OpDescPtr &op_desc) { | 78 | bool IsWrapperNode(const OpDescPtr &op_desc) { |
| 79 | return !op_desc->GetSubgraphInstanceNames().empty(); | 79 | return !op_desc->GetSubgraphInstanceNames().empty(); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | -void PrintPaths(const Paths &paths) { | 82 | +void PrintPaths(const TransPaths &paths) { |
| 83 | - GELOGI("Paths size: %zu", paths.size()); | 83 | + GELOGI("TransPaths size: %zu", paths.size()); |
| 84 | for (size_t i = 0U; i < paths.size(); ++i) { | 84 | for (size_t i = 0U; i < paths.size(); ++i) { |
| 85 | if (!paths[i].empty()) { | 85 | if (!paths[i].empty()) { |
| 86 | std::stringstream ss; | 86 | std::stringstream ss; |
| @@ -103,7 +103,7 @@ void PrintPaths(const Paths &paths) { | |||
| 103 | } | 103 | } |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | -void PrintFusedTransdata(const std::vector<Paths> &same_transdata_paths_groups) { | 106 | +void PrintFusedTransdata(const std::vector<TransPaths> &same_transdata_paths_groups) { |
| 107 | for (const auto &same_transdata_paths : same_transdata_paths_groups) { | 107 | for (const auto &same_transdata_paths : same_transdata_paths_groups) { |
| 108 | std::stringstream ss; | 108 | std::stringstream ss; |
| 109 | auto iter = same_transdata_paths.begin(); | 109 | auto iter = same_transdata_paths.begin(); |
| @@ -120,7 +120,7 @@ void PrintFusedTransdata(const std::vector<Paths> &same_transdata_paths_groups) | |||
| 120 | 120 | ||
| 121 | // avoid scene 1: A->Cast->TransData while A's DataType is not supported by TransData | 121 | // avoid scene 1: A->Cast->TransData while A's DataType is not supported by TransData |
| 122 | // avoid scene 2: A->Cast->TransData while the output format of TransData is not supported by Cast | 122 | // avoid scene 2: A->Cast->TransData while the output format of TransData is not supported by Cast |
| 123 | -graphStatus CheckOpSupported(const Path &path, const LinkNode &link_node, bool &is_supported) { | 123 | +graphStatus CheckOpSupported(const TransPath &path, const PathLinkNode &link_node, bool &is_supported) { |
| 124 | if (path.empty()) { | 124 | if (path.empty()) { |
| 125 | is_supported = true; | 125 | is_supported = true; |
| 126 | return GRAPH_SUCCESS; | 126 | return GRAPH_SUCCESS; |
| @@ -187,14 +187,14 @@ graphStatus CheckOpSupported(const Path &path, const LinkNode &link_node, bool & | |||
| 187 | return GRAPH_SUCCESS; | 187 | return GRAPH_SUCCESS; |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | -std::set<std::string> GetInControlIdentityNodes(const Path &path, const LinkNode &transdata_link_node) { | 190 | +std::set<std::string> GetInControlIdentityNodes(const TransPath &path, const PathLinkNode &transdata_link_node) { |
| 191 | std::set<std::string> in_node_names; | 191 | std::set<std::string> in_node_names; |
| 192 | const auto &transdata_node = transdata_link_node.in_anchor->GetOwnerNode(); | 192 | const auto &transdata_node = transdata_link_node.in_anchor->GetOwnerNode(); |
| 193 | for (const auto &in_node : transdata_node->GetInControlNodes()) { | 193 | for (const auto &in_node : transdata_node->GetInControlNodes()) { |
| 194 | in_node_names.insert(in_node->GetName()); | 194 | in_node_names.insert(in_node->GetName()); |
| 195 | } | 195 | } |
| 196 | for (const auto &link_node : path) { | 196 | for (const auto &link_node : path) { |
| 197 | - if (link_node.node_type == NodeType::kTransdata) { | 197 | + if (link_node.node_type == LinkNodeType::kTransdata) { |
| 198 | break; | 198 | break; |
| 199 | } | 199 | } |
| 200 | const auto node = link_node.in_anchor->GetOwnerNode(); | 200 | const auto node = link_node.in_anchor->GetOwnerNode(); |
| @@ -296,7 +296,7 @@ NodePtr CreateDataNode(ComputeGraphPtr &sub_graph, const size_t parent_index) { | |||
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | // 找到topoid最小的那个,否则有可能成环 | 298 | // 找到topoid最小的那个,否则有可能成环 |
| 299 | -size_t GetKeepTransdataPathIndex(const Paths &paths_group) { | 299 | +size_t GetKeepTransdataPathIndex(const TransPaths &paths_group) { |
| 300 | size_t keep_transdata_path_index = 0U; | 300 | size_t keep_transdata_path_index = 0U; |
| 301 | 301 | ||
| 302 | for (size_t i = 1U; i < paths_group.size(); ++i) { | 302 | for (size_t i = 1U; i < paths_group.size(); ++i) { |
| @@ -341,7 +341,8 @@ graphStatus ConnetToFusedAnchors(std::vector<InDataAnchorPtr> &fused_anchors, co | |||
| 341 | return GRAPH_SUCCESS; | 341 | return GRAPH_SUCCESS; |
| 342 | } | 342 | } |
| 343 | 343 | ||
| 344 | -bool IsAllNodeInPathsWithSameTransdata(const std::set<InDataAnchorPtr> &allowed_set, std::queue<Path> &path_queue) { | 344 | +bool IsAllNodeInPathsWithSameTransdata(const std::set<InDataAnchorPtr> &allowed_set, |
| 345 | + std::queue<TransPath> &path_queue) { | ||
| 345 | while (!path_queue.empty()) { | 346 | while (!path_queue.empty()) { |
| 346 | const auto &path = path_queue.front(); | 347 | const auto &path = path_queue.front(); |
| 347 | for (const auto &node : path) { | 348 | for (const auto &node : path) { |
| @@ -468,7 +469,7 @@ graphStatus SameTransdataBreadthFusionPass::DoRun(ComputeGraphPtr graph) { | |||
| 468 | } | 469 | } |
| 469 | 470 | ||
| 470 | graphStatus SameTransdataBreadthFusionPass::RunForNode(OutDataAnchorPtr &head_out_anchor) { | 471 | graphStatus SameTransdataBreadthFusionPass::RunForNode(OutDataAnchorPtr &head_out_anchor) { |
| 471 | - Paths paths; | 472 | + TransPaths paths; |
| 472 | GE_ASSERT_SUCCESS(GetPathsToTransdata(head_out_anchor, paths)); | 473 | GE_ASSERT_SUCCESS(GetPathsToTransdata(head_out_anchor, paths)); |
| 473 | if (paths.size() <= 1U) { | 474 | if (paths.size() <= 1U) { |
| 474 | return GRAPH_SUCCESS; | 475 | return GRAPH_SUCCESS; |
| @@ -479,10 +480,10 @@ graphStatus SameTransdataBreadthFusionPass::RunForNode(OutDataAnchorPtr &head_ou | |||
| 479 | } | 480 | } |
| 480 | 481 | ||
| 481 | graphStatus SameTransdataBreadthFusionPass::GetPathsToTransdata(const OutDataAnchorPtr &head_out_anchor, | 482 | graphStatus SameTransdataBreadthFusionPass::GetPathsToTransdata(const OutDataAnchorPtr &head_out_anchor, |
| 482 | - Paths &paths) const { | 483 | + TransPaths &paths) const { |
| 483 | - std::queue<Path> path_queue; | 484 | + std::queue<TransPath> path_queue; |
| 484 | bool is_supported = false; | 485 | bool is_supported = false; |
| 485 | - GE_ASSERT_SUCCESS(GetRealInAnchors(head_out_anchor, head_out_anchor, path_queue, Path())); | 486 | + GE_ASSERT_SUCCESS(GetRealInAnchors(head_out_anchor, head_out_anchor, path_queue, TransPath())); |
| 486 | while (!path_queue.empty()) { | 487 | while (!path_queue.empty()) { |
| 487 | auto cur_path = path_queue.front(); // copy | 488 | auto cur_path = path_queue.front(); // copy |
| 488 | path_queue.pop(); | 489 | path_queue.pop(); |
| @@ -490,24 +491,24 @@ graphStatus SameTransdataBreadthFusionPass::GetPathsToTransdata(const OutDataAnc | |||
| 490 | const auto &link_node = cur_path.back(); | 491 | const auto &link_node = cur_path.back(); |
| 491 | const auto &owner_node = link_node.in_anchor->GetOwnerNode(); | 492 | const auto &owner_node = link_node.in_anchor->GetOwnerNode(); |
| 492 | switch (link_node.node_type) { | 493 | switch (link_node.node_type) { |
| 493 | - case NodeType::kTransdata : | 494 | + case LinkNodeType::kTransdata : |
| 494 | GE_ASSERT_SUCCESS(CheckOpSupported(cur_path, link_node, is_supported)); | 495 | GE_ASSERT_SUCCESS(CheckOpSupported(cur_path, link_node, is_supported)); |
| 495 | if ((owner_node->GetOutDataNodesSize() != 0U) && is_supported) { | 496 | if ((owner_node->GetOutDataNodesSize() != 0U) && is_supported) { |
| 496 | // 这里保证path的最后一个节点一定是transdata | 497 | // 这里保证path的最后一个节点一定是transdata |
| 497 | paths.emplace_back(std::move(cur_path)); | 498 | paths.emplace_back(std::move(cur_path)); |
| 498 | } | 499 | } |
| 499 | break; | 500 | break; |
| 500 | - case NodeType::kCast: | 501 | + case LinkNodeType::kCast: |
| 501 | // path中在transdata前面如果有其他节点的话,这里保证一定是cast | 502 | // path中在transdata前面如果有其他节点的话,这里保证一定是cast |
| 502 | for (const auto &cast_out_anchor : owner_node->GetAllOutDataAnchors()) { | 503 | for (const auto &cast_out_anchor : owner_node->GetAllOutDataAnchors()) { |
| 503 | GE_ASSERT_SUCCESS(GetRealInAnchors(cast_out_anchor, cast_out_anchor, path_queue, cur_path)); | 504 | GE_ASSERT_SUCCESS(GetRealInAnchors(cast_out_anchor, cast_out_anchor, path_queue, cur_path)); |
| 504 | } | 505 | } |
| 505 | break; | 506 | break; |
| 506 | - case NodeType::kOthers: | 507 | + case LinkNodeType::kOthers: |
| 507 | break; | 508 | break; |
| 508 | - case NodeType::kData: | 509 | + case LinkNodeType::kData: |
| 509 | - case NodeType::kNetOutput: | 510 | + case LinkNodeType::kNetOutput: |
| 510 | - case NodeType::kWrapperNode: | 511 | + case LinkNodeType::kWrapperNode: |
| 511 | GELOGE(FAILED, "type: %s node name: %s should not be here.", | 512 | GELOGE(FAILED, "type: %s node name: %s should not be here.", |
| 512 | owner_node->GetTypePtr(), owner_node->GetNamePtr()); | 513 | owner_node->GetTypePtr(), owner_node->GetNamePtr()); |
| 513 | return GRAPH_FAILED; | 514 | return GRAPH_FAILED; |
| @@ -518,8 +519,8 @@ graphStatus SameTransdataBreadthFusionPass::GetPathsToTransdata(const OutDataAnc | |||
| 518 | 519 | ||
| 519 | graphStatus SameTransdataBreadthFusionPass::GetRealInAnchors(const OutDataAnchorPtr &real_out_anchor, | 520 | graphStatus SameTransdataBreadthFusionPass::GetRealInAnchors(const OutDataAnchorPtr &real_out_anchor, |
| 520 | const OutDataAnchorPtr &out_anchor, | 521 | const OutDataAnchorPtr &out_anchor, |
| 521 | - std::queue<Path> &path_queue, | 522 | + std::queue<TransPath> &path_queue, |
| 522 | - const Path &path) const { | 523 | + const TransPath &path) const { |
| 523 | std::stack<OutDataAnchorPtr> out_anchor_stack; | 524 | std::stack<OutDataAnchorPtr> out_anchor_stack; |
| 524 | out_anchor_stack.push(out_anchor); | 525 | out_anchor_stack.push(out_anchor); |
| 525 | while (!out_anchor_stack.empty()) { | 526 | while (!out_anchor_stack.empty()) { |
| @@ -533,8 +534,8 @@ graphStatus SameTransdataBreadthFusionPass::GetRealInAnchors(const OutDataAnchor | |||
| 533 | } else if (next_node->GetType() == NETOUTPUT) { | 534 | } else if (next_node->GetType() == NETOUTPUT) { |
| 534 | GE_ASSERT_SUCCESS(GetRealInAnchorsForNetOutput(real_out_anchor, in_anchor, path, out_anchor_stack)); | 535 | GE_ASSERT_SUCCESS(GetRealInAnchorsForNetOutput(real_out_anchor, in_anchor, path, out_anchor_stack)); |
| 535 | } else { | 536 | } else { |
| 536 | - Path new_path(path); | 537 | + TransPath new_path(path); |
| 537 | - new_path.emplace_back(LinkNode{in_anchor, real_out_anchor, GetNodeType(next_node)}); | 538 | + new_path.emplace_back(PathLinkNode{in_anchor, real_out_anchor, GetNodeType(next_node)}); |
| 538 | path_queue.push(std::move(new_path)); | 539 | path_queue.push(std::move(new_path)); |
| 539 | } | 540 | } |
| 540 | } | 541 | } |
| @@ -578,7 +579,7 @@ graphStatus SameTransdataBreadthFusionPass::GetSubgraphDataOutAnchor(const Compu | |||
| 578 | } | 579 | } |
| 579 | 580 | ||
| 580 | graphStatus SameTransdataBreadthFusionPass::GetRealInAnchorsForNetOutput( | 581 | graphStatus SameTransdataBreadthFusionPass::GetRealInAnchorsForNetOutput( |
| 581 | - const OutDataAnchorPtr &real_out_anchor, const InDataAnchorPtr &in_anchor, const Path &path, | 582 | + const OutDataAnchorPtr &real_out_anchor, const InDataAnchorPtr &in_anchor, const TransPath &path, |
| 582 | std::stack<OutDataAnchorPtr> &out_anchor_stack) const { | 583 | std::stack<OutDataAnchorPtr> &out_anchor_stack) const { |
| 583 | const auto &netoutput = in_anchor->GetOwnerNode(); | 584 | const auto &netoutput = in_anchor->GetOwnerNode(); |
| 584 | const auto &op_desc = netoutput->GetOpDesc(); | 585 | const auto &op_desc = netoutput->GetOpDesc(); |
| @@ -617,8 +618,8 @@ graphStatus SameTransdataBreadthFusionPass::GetRealInAnchorsForNetOutput( | |||
| 617 | return GRAPH_SUCCESS; | 618 | return GRAPH_SUCCESS; |
| 618 | } | 619 | } |
| 619 | 620 | ||
| 620 | -graphStatus SameTransdataBreadthFusionPass::FuseTransdata(Paths &paths) { | 621 | +graphStatus SameTransdataBreadthFusionPass::FuseTransdata(TransPaths &paths) { |
| 621 | - std::vector<Paths> same_transdata_paths_groups; | 622 | + std::vector<TransPaths> same_transdata_paths_groups; |
| 622 | GE_ASSERT_SUCCESS(GetSameTransdataPath(paths, same_transdata_paths_groups)); | 623 | GE_ASSERT_SUCCESS(GetSameTransdataPath(paths, same_transdata_paths_groups)); |
| 623 | 624 | ||
| 624 | auto iter = same_transdata_paths_groups.begin(); | 625 | auto iter = same_transdata_paths_groups.begin(); |
| @@ -647,22 +648,22 @@ graphStatus SameTransdataBreadthFusionPass::FuseTransdata(Paths &paths) { | |||
| 647 | return GRAPH_SUCCESS; | 648 | return GRAPH_SUCCESS; |
| 648 | } | 649 | } |
| 649 | 650 | ||
| 650 | -graphStatus SameTransdataBreadthFusionPass::GetSameTransdataPath(Paths &paths, | 651 | +graphStatus SameTransdataBreadthFusionPass::GetSameTransdataPath(TransPaths &paths, |
| 651 | - std::vector<Paths> &same_transdata_paths_groups) { | 652 | + std::vector<TransPaths> &same_transdata_paths_groups) { |
| 652 | while (paths.size() > 1U) { | 653 | while (paths.size() > 1U) { |
| 653 | auto iter = paths.begin(); | 654 | auto iter = paths.begin(); |
| 654 | - Paths same_transdata_paths; | 655 | + TransPaths same_transdata_paths; |
| 655 | same_transdata_paths.emplace_back(std::move(*iter)); | 656 | same_transdata_paths.emplace_back(std::move(*iter)); |
| 656 | const auto &first_path = same_transdata_paths.front(); | 657 | const auto &first_path = same_transdata_paths.front(); |
| 657 | 658 | ||
| 658 | iter = paths.erase(iter); | 659 | iter = paths.erase(iter); |
| 659 | - LinkNode first_transdata = first_path.back(); | 660 | + PathLinkNode first_transdata = first_path.back(); |
| 660 | CompareInfo first_info; | 661 | CompareInfo first_info; |
| 661 | GE_ASSERT_SUCCESS(GetCompareInfo(first_path, first_transdata, first_info)); | 662 | GE_ASSERT_SUCCESS(GetCompareInfo(first_path, first_transdata, first_info)); |
| 662 | 663 | ||
| 663 | while (iter != paths.end()) { | 664 | while (iter != paths.end()) { |
| 664 | auto &another_path = *iter; | 665 | auto &another_path = *iter; |
| 665 | - LinkNode another_transdata = another_path.back(); | 666 | + PathLinkNode another_transdata = another_path.back(); |
| 666 | CompareInfo another_info; | 667 | CompareInfo another_info; |
| 667 | GE_ASSERT_SUCCESS(GetCompareInfo(another_path, another_transdata, another_info)); | 668 | GE_ASSERT_SUCCESS(GetCompareInfo(another_path, another_transdata, another_info)); |
| 668 | if (IsSame(first_info, another_info)) { | 669 | if (IsSame(first_info, another_info)) { |
| @@ -703,7 +704,7 @@ graphStatus SameTransdataBreadthFusionPass::GetSameTransdataPath(Paths &paths, | |||
| 703 | * +------+ | 704 | * +------+ |
| 704 | * add new path from op to transdata3 | 705 | * add new path from op to transdata3 |
| 705 | */ | 706 | */ |
| 706 | -graphStatus SameTransdataBreadthFusionPass::AddNewPathToTransdataForDiffGraph(Paths &paths_group) { | 707 | +graphStatus SameTransdataBreadthFusionPass::AddNewPathToTransdataForDiffGraph(TransPaths &paths_group) { |
| 707 | auto head_out_anchor = paths_group[0].front().real_peer_out_anchor; | 708 | auto head_out_anchor = paths_group[0].front().real_peer_out_anchor; |
| 708 | std::set<InDataAnchorPtr> allowed_in_anchors; | 709 | std::set<InDataAnchorPtr> allowed_in_anchors; |
| 709 | for (const auto &cur_path : paths_group) { | 710 | for (const auto &cur_path : paths_group) { |
| @@ -727,7 +728,7 @@ graphStatus SameTransdataBreadthFusionPass::AddNewPath(OutDataAnchorPtr &out_anc | |||
| 727 | const auto head_next = peer_in_anchor->GetOwnerNode(); | 728 | const auto head_next = peer_in_anchor->GetOwnerNode(); |
| 728 | GE_ASSERT_NOTNULL(head_next->GetOpDescBarePtr()); | 729 | GE_ASSERT_NOTNULL(head_next->GetOpDescBarePtr()); |
| 729 | const auto head_next_type = GetNodeType(head_next); | 730 | const auto head_next_type = GetNodeType(head_next); |
| 730 | - if ((head_next_type != NodeType::kWrapperNode) && (head_next_type != NodeType::kNetOutput)) { | 731 | + if ((head_next_type != LinkNodeType::kWrapperNode) && (head_next_type != LinkNodeType::kNetOutput)) { |
| 731 | if (allowed_in_anchors.find(peer_in_anchor) != allowed_in_anchors.end()) { | 732 | if (allowed_in_anchors.find(peer_in_anchor) != allowed_in_anchors.end()) { |
| 732 | GE_ASSERT_SUCCESS(peer_in_anchor->Unlink(peer_in_anchor->GetPeerOutAnchor())); | 733 | GE_ASSERT_SUCCESS(peer_in_anchor->Unlink(peer_in_anchor->GetPeerOutAnchor())); |
| 733 | GE_ASSERT_SUCCESS(cur_new_out_anchor->LinkTo(peer_in_anchor)); | 734 | GE_ASSERT_SUCCESS(cur_new_out_anchor->LinkTo(peer_in_anchor)); |
| @@ -762,7 +763,7 @@ graphStatus SameTransdataBreadthFusionPass::AddNewPath(OutDataAnchorPtr &out_anc | |||
| 762 | auto new_in_anchor = head_next->GetInDataAnchor(input_size); | 763 | auto new_in_anchor = head_next->GetInDataAnchor(input_size); |
| 763 | GE_ASSERT_SUCCESS(cur_new_out_anchor->LinkTo(new_in_anchor)); | 764 | GE_ASSERT_SUCCESS(cur_new_out_anchor->LinkTo(new_in_anchor)); |
| 764 | 765 | ||
| 765 | - if (head_next_type == NodeType::kWrapperNode) { | 766 | + if (head_next_type == LinkNodeType::kWrapperNode) { |
| 766 | GE_ASSERT_SUCCESS(AddNewInputForWrapper(peer_in_anchor, fused_anchors, out_anchor_pair_stack)); | 767 | GE_ASSERT_SUCCESS(AddNewInputForWrapper(peer_in_anchor, fused_anchors, out_anchor_pair_stack)); |
| 767 | } else { | 768 | } else { |
| 768 | GE_ASSERT_SUCCESS(AddNewInputForNetOutput(peer_in_anchor, fused_anchors, out_anchor_pair_stack)); | 769 | GE_ASSERT_SUCCESS(AddNewInputForNetOutput(peer_in_anchor, fused_anchors, out_anchor_pair_stack)); |
| @@ -856,7 +857,7 @@ void SameTransdataBreadthFusionPass::UpdateGraphNode(const ComputeGraphPtr &sub_ | |||
| 856 | } | 857 | } |
| 857 | 858 | ||
| 858 | // cast的输出都是相同的transdata,如果不满足这一点,删掉这个path | 859 | // cast的输出都是相同的transdata,如果不满足这一点,删掉这个path |
| 859 | -graphStatus SameTransdataBreadthFusionPass::RemoveUnSupportedPath(Paths &paths_with_same_transdata) const { | 860 | +graphStatus SameTransdataBreadthFusionPass::RemoveUnSupportedPath(TransPaths &paths_with_same_transdata) const { |
| 860 | std::set<InDataAnchorPtr> allowed_set; | 861 | std::set<InDataAnchorPtr> allowed_set; |
| 861 | for (const auto &path : paths_with_same_transdata) { | 862 | for (const auto &path : paths_with_same_transdata) { |
| 862 | for (const auto &node : path) { | 863 | for (const auto &node : path) { |
| @@ -865,12 +866,12 @@ graphStatus SameTransdataBreadthFusionPass::RemoveUnSupportedPath(Paths &paths_w | |||
| 865 | } | 866 | } |
| 866 | auto path_iter = paths_with_same_transdata.begin(); | 867 | auto path_iter = paths_with_same_transdata.begin(); |
| 867 | while (path_iter != paths_with_same_transdata.end()) { | 868 | while (path_iter != paths_with_same_transdata.end()) { |
| 868 | - std::queue<Path> path_queue; | 869 | + std::queue<TransPath> path_queue; |
| 869 | // path最后一个节点是transdata,前面如果有节点的话,一定都是cast节点。获取所有cast节点的real in anchor | 870 | // path最后一个节点是transdata,前面如果有节点的话,一定都是cast节点。获取所有cast节点的real in anchor |
| 870 | for (size_t i = 0U; i < path_iter->size() - 1U; ++i) { | 871 | for (size_t i = 0U; i < path_iter->size() - 1U; ++i) { |
| 871 | const auto &cast_node = path_iter->at(i); | 872 | const auto &cast_node = path_iter->at(i); |
| 872 | for (auto &out_data_anchor : cast_node.in_anchor->GetOwnerNodeBarePtr()->GetAllOutDataAnchors()) { | 873 | for (auto &out_data_anchor : cast_node.in_anchor->GetOwnerNodeBarePtr()->GetAllOutDataAnchors()) { |
| 873 | - GE_ASSERT_SUCCESS(GetRealInAnchors(out_data_anchor, out_data_anchor, path_queue, Path())); | 874 | + GE_ASSERT_SUCCESS(GetRealInAnchors(out_data_anchor, out_data_anchor, path_queue, TransPath())); |
| 874 | } | 875 | } |
| 875 | } | 876 | } |
| 876 | if (!IsAllNodeInPathsWithSameTransdata(allowed_set, path_queue)) { | 877 | if (!IsAllNodeInPathsWithSameTransdata(allowed_set, path_queue)) { |
| @@ -884,7 +885,7 @@ graphStatus SameTransdataBreadthFusionPass::RemoveUnSupportedPath(Paths &paths_w | |||
| 884 | return GRAPH_SUCCESS; | 885 | return GRAPH_SUCCESS; |
| 885 | } | 886 | } |
| 886 | 887 | ||
| 887 | -graphStatus SameTransdataBreadthFusionPass::GetCompareInfo(const Path &path, const LinkNode &link_node, | 888 | +graphStatus SameTransdataBreadthFusionPass::GetCompareInfo(const TransPath &path, const PathLinkNode &link_node, |
| 888 | CompareInfo &info) { | 889 | CompareInfo &info) { |
| 889 | const auto &node = link_node.in_anchor->GetOwnerNode(); | 890 | const auto &node = link_node.in_anchor->GetOwnerNode(); |
| 890 | const auto &iter = node_to_info_map_.find(node); | 891 | const auto &iter = node_to_info_map_.find(node); |
| @@ -906,7 +907,7 @@ graphStatus SameTransdataBreadthFusionPass::GetCompareInfo(const Path &path, con | |||
| 906 | return GRAPH_SUCCESS; | 907 | return GRAPH_SUCCESS; |
| 907 | } | 908 | } |
| 908 | 909 | ||
| 909 | -graphStatus SameTransdataBreadthFusionPass::UpdateTensorDesc(const Paths &paths_group, | 910 | +graphStatus SameTransdataBreadthFusionPass::UpdateTensorDesc(const TransPaths &paths_group, |
| 910 | size_t keep_transdata_path_index) { | 911 | size_t keep_transdata_path_index) { |
| 911 | const auto trans = paths_group[keep_transdata_path_index].back().in_anchor->GetOwnerNodeBarePtr(); | 912 | const auto trans = paths_group[keep_transdata_path_index].back().in_anchor->GetOwnerNodeBarePtr(); |
| 912 | const auto head_out_anchor = paths_group[keep_transdata_path_index].front().real_peer_out_anchor; | 913 | const auto head_out_anchor = paths_group[keep_transdata_path_index].front().real_peer_out_anchor; |
| @@ -935,8 +936,8 @@ graphStatus SameTransdataBreadthFusionPass::UpdateTensorDesc(const Paths &paths_ | |||
| 935 | } | 936 | } |
| 936 | 937 | ||
| 937 | graphStatus SameTransdataBreadthFusionPass::UpdateTensorDescForDiffGraph( | 938 | graphStatus SameTransdataBreadthFusionPass::UpdateTensorDescForDiffGraph( |
| 938 | - const GeTensorDesc &trans_out_tensor_desc, const LinkNode &link_node) { | 939 | + const GeTensorDesc &trans_out_tensor_desc, const PathLinkNode &link_node) { |
| 939 | - std::stack<LinkNode> link_node_stack; | 940 | + std::stack<PathLinkNode> link_node_stack; |
| 940 | link_node_stack.push(link_node); | 941 | link_node_stack.push(link_node); |
| 941 | while (!link_node_stack.empty()) { | 942 | while (!link_node_stack.empty()) { |
| 942 | const auto cur_link_node = link_node_stack.top(); | 943 | const auto cur_link_node = link_node_stack.top(); |
| @@ -944,12 +945,12 @@ graphStatus SameTransdataBreadthFusionPass::UpdateTensorDescForDiffGraph( | |||
| 944 | const auto &pre_node = cur_link_node.in_anchor->GetPeerOutAnchor()->GetOwnerNode(); | 945 | const auto &pre_node = cur_link_node.in_anchor->GetPeerOutAnchor()->GetOwnerNode(); |
| 945 | GE_ASSERT_NOTNULL(pre_node->GetOpDescBarePtr()); | 946 | GE_ASSERT_NOTNULL(pre_node->GetOpDescBarePtr()); |
| 946 | const auto pre_node_type = GetNodeType(pre_node); | 947 | const auto pre_node_type = GetNodeType(pre_node); |
| 947 | - GE_ASSERT_TRUE((pre_node_type == NodeType::kData) || (pre_node_type == NodeType::kWrapperNode), | 948 | + GE_ASSERT_TRUE((pre_node_type == LinkNodeType::kData) || (pre_node_type == LinkNodeType::kWrapperNode), |
| 948 | "current node %s must connect to Data or Wrapper, but pre_node %s node type is %u", | 949 | "current node %s must connect to Data or Wrapper, but pre_node %s node type is %u", |
| 949 | cur_link_node.in_anchor->GetOwnerNodeBarePtr()->GetNamePtr(), pre_node->GetNamePtr(), | 950 | cur_link_node.in_anchor->GetOwnerNodeBarePtr()->GetNamePtr(), pre_node->GetNamePtr(), |
| 950 | static_cast<uint32_t>(pre_node_type)); | 951 | static_cast<uint32_t>(pre_node_type)); |
| 951 | 952 | ||
| 952 | - if (pre_node_type == NodeType::kData) { | 953 | + if (pre_node_type == LinkNodeType::kData) { |
| 953 | GE_ASSERT_SUCCESS(UpdateTensorDescForConnectData(trans_out_tensor_desc, cur_link_node, link_node_stack)); | 954 | GE_ASSERT_SUCCESS(UpdateTensorDescForConnectData(trans_out_tensor_desc, cur_link_node, link_node_stack)); |
| 954 | } else { | 955 | } else { |
| 955 | GE_ASSERT_SUCCESS(UpdateTensorDescForConnectWrapper(trans_out_tensor_desc, cur_link_node, link_node_stack)); | 956 | GE_ASSERT_SUCCESS(UpdateTensorDescForConnectWrapper(trans_out_tensor_desc, cur_link_node, link_node_stack)); |
| @@ -960,7 +961,8 @@ graphStatus SameTransdataBreadthFusionPass::UpdateTensorDescForDiffGraph( | |||
| 960 | } | 961 | } |
| 961 | 962 | ||
| 962 | graphStatus SameTransdataBreadthFusionPass::UpdateTensorDescForConnectData( | 963 | graphStatus SameTransdataBreadthFusionPass::UpdateTensorDescForConnectData( |
| 963 | - const GeTensorDesc &trans_out_tensor_desc, const LinkNode &link_node, std::stack<LinkNode> &link_node_stack) const { | 964 | + const GeTensorDesc &trans_out_tensor_desc, const PathLinkNode &link_node, |
| 965 | + std::stack<PathLinkNode> &link_node_stack) const { | ||
| 964 | const auto &owner_node = link_node.in_anchor->GetOwnerNode(); | 966 | const auto &owner_node = link_node.in_anchor->GetOwnerNode(); |
| 965 | const auto owner_graph = owner_node->GetOwnerComputeGraphBarePtr(); | 967 | const auto owner_graph = owner_node->GetOwnerComputeGraphBarePtr(); |
| 966 | GE_ASSERT_NOTNULL(owner_graph->GetParentNode()); | 968 | GE_ASSERT_NOTNULL(owner_graph->GetParentNode()); |
| @@ -988,7 +990,7 @@ graphStatus SameTransdataBreadthFusionPass::UpdateTensorDescForConnectData( | |||
| 988 | const auto peer_out_anchor = wrapper_in_anchor->GetPeerOutAnchor(); | 990 | const auto peer_out_anchor = wrapper_in_anchor->GetPeerOutAnchor(); |
| 989 | GE_ASSERT_NOTNULL(peer_out_anchor); | 991 | GE_ASSERT_NOTNULL(peer_out_anchor); |
| 990 | if (peer_out_anchor != link_node.real_peer_out_anchor) { | 992 | if (peer_out_anchor != link_node.real_peer_out_anchor) { |
| 991 | - const LinkNode new_link_node{wrapper_in_anchor, link_node.real_peer_out_anchor, NodeType::kWrapperNode}; | 993 | + const PathLinkNode new_link_node{wrapper_in_anchor, link_node.real_peer_out_anchor, LinkNodeType::kWrapperNode}; |
| 992 | link_node_stack.push(new_link_node); | 994 | link_node_stack.push(new_link_node); |
| 993 | } | 995 | } |
| 994 | 996 | ||
| @@ -1007,7 +1009,8 @@ graphStatus SameTransdataBreadthFusionPass::UpdateTensorDescForConnectData( | |||
| 1007 | } | 1009 | } |
| 1008 | 1010 | ||
| 1009 | graphStatus SameTransdataBreadthFusionPass::UpdateTensorDescForConnectWrapper( | 1011 | graphStatus SameTransdataBreadthFusionPass::UpdateTensorDescForConnectWrapper( |
| 1010 | - const GeTensorDesc &trans_out_tensor_desc, const LinkNode &link_node, std::stack<LinkNode> &link_node_stack) { | 1012 | + const GeTensorDesc &trans_out_tensor_desc, const PathLinkNode &link_node, |
| 1013 | + std::stack<PathLinkNode> &link_node_stack) { | ||
| 1011 | GE_ASSERT_NOTNULL(link_node.in_anchor->GetPeerOutAnchor()); | 1014 | GE_ASSERT_NOTNULL(link_node.in_anchor->GetPeerOutAnchor()); |
| 1012 | const auto &wrapper_node = link_node.in_anchor->GetPeerOutAnchor()->GetOwnerNode(); | 1015 | const auto &wrapper_node = link_node.in_anchor->GetPeerOutAnchor()->GetOwnerNode(); |
| 1013 | const auto &wrapper_op_desc = wrapper_node->GetOpDesc(); | 1016 | const auto &wrapper_op_desc = wrapper_node->GetOpDesc(); |
| @@ -1056,14 +1059,14 @@ graphStatus SameTransdataBreadthFusionPass::UpdateTensorDescForConnectWrapper( | |||
| 1056 | const auto peer_out_anchor = netoutput_in_anchor->GetPeerOutAnchor(); | 1059 | const auto peer_out_anchor = netoutput_in_anchor->GetPeerOutAnchor(); |
| 1057 | GE_ASSERT_NOTNULL(peer_out_anchor); | 1060 | GE_ASSERT_NOTNULL(peer_out_anchor); |
| 1058 | if (peer_out_anchor != link_node.real_peer_out_anchor) { | 1061 | if (peer_out_anchor != link_node.real_peer_out_anchor) { |
| 1059 | - const LinkNode new_link_node{netoutput_in_anchor, link_node.real_peer_out_anchor, NodeType::kNetOutput}; | 1062 | + const PathLinkNode new_link_node{netoutput_in_anchor, link_node.real_peer_out_anchor, LinkNodeType::kNetOutput}; |
| 1060 | link_node_stack.push(new_link_node); | 1063 | link_node_stack.push(new_link_node); |
| 1061 | } | 1064 | } |
| 1062 | } | 1065 | } |
| 1063 | return GRAPH_SUCCESS; | 1066 | return GRAPH_SUCCESS; |
| 1064 | } | 1067 | } |
| 1065 | 1068 | ||
| 1066 | -graphStatus SameTransdataBreadthFusionPass::ExtractTransdata(const Paths &paths_group, | 1069 | +graphStatus SameTransdataBreadthFusionPass::ExtractTransdata(const TransPaths &paths_group, |
| 1067 | size_t keep_transdata_path_index) const { | 1070 | size_t keep_transdata_path_index) const { |
| 1068 | const auto &path = paths_group[keep_transdata_path_index]; | 1071 | const auto &path = paths_group[keep_transdata_path_index]; |
| 1069 | auto trans_in_anchor = path.back().in_anchor; | 1072 | auto trans_in_anchor = path.back().in_anchor; |
| @@ -1094,7 +1097,7 @@ graphStatus SameTransdataBreadthFusionPass::ExtractTransdata(const Paths &paths_ | |||
| 1094 | return GRAPH_SUCCESS; | 1097 | return GRAPH_SUCCESS; |
| 1095 | } | 1098 | } |
| 1096 | 1099 | ||
| 1097 | -graphStatus SameTransdataBreadthFusionPass::LinkHeadToTransdata(const Paths &paths_group, | 1100 | +graphStatus SameTransdataBreadthFusionPass::LinkHeadToTransdata(const TransPaths &paths_group, |
| 1098 | size_t keep_transdata_path_index) const { | 1101 | size_t keep_transdata_path_index) const { |
| 1099 | const auto &path = paths_group[keep_transdata_path_index]; | 1102 | const auto &path = paths_group[keep_transdata_path_index]; |
| 1100 | const auto head_out_anchor = path.front().real_peer_out_anchor; | 1103 | const auto head_out_anchor = path.front().real_peer_out_anchor; |
| @@ -1112,7 +1115,7 @@ graphStatus SameTransdataBreadthFusionPass::LinkHeadToTransdata(const Paths &pat | |||
| 1112 | const auto head_next = peer_in_anchor->GetOwnerNode(); | 1115 | const auto head_next = peer_in_anchor->GetOwnerNode(); |
| 1113 | GE_ASSERT_NOTNULL(head_next->GetOpDescBarePtr()); | 1116 | GE_ASSERT_NOTNULL(head_next->GetOpDescBarePtr()); |
| 1114 | const auto head_next_type = GetNodeType(head_next); | 1117 | const auto head_next_type = GetNodeType(head_next); |
| 1115 | - if ((head_next_type != NodeType::kWrapperNode) && (head_next_type != NodeType::kNetOutput)) { | 1118 | + if ((head_next_type != LinkNodeType::kWrapperNode) && (head_next_type != LinkNodeType::kNetOutput)) { |
| 1116 | if (allowed_in_anchors.find(peer_in_anchor) != allowed_in_anchors.end()) { | 1119 | if (allowed_in_anchors.find(peer_in_anchor) != allowed_in_anchors.end()) { |
| 1117 | peer_in_anchor->UnlinkAll(); | 1120 | peer_in_anchor->UnlinkAll(); |
| 1118 | if (peer_in_anchor->GetOwnerNode() != trans) { | 1121 | if (peer_in_anchor->GetOwnerNode() != trans) { |
| @@ -1142,14 +1145,14 @@ graphStatus SameTransdataBreadthFusionPass::LinkHeadToTransdata(const Paths &pat | |||
| 1142 | 1145 | ||
| 1143 | graphStatus SameTransdataBreadthFusionPass::CollectFusedInAnchors( | 1146 | graphStatus SameTransdataBreadthFusionPass::CollectFusedInAnchors( |
| 1144 | const InDataAnchorPtr &in_anchor, const std::set<InDataAnchorPtr> &allowed_in_anchors, | 1147 | const InDataAnchorPtr &in_anchor, const std::set<InDataAnchorPtr> &allowed_in_anchors, |
| 1145 | - const NodeType head_next_type, std::vector<InDataAnchorPtr> &fused_anchors, | 1148 | + const LinkNodeType head_next_type, std::vector<InDataAnchorPtr> &fused_anchors, |
| 1146 | std::vector<InDataAnchorPtr> ¬_fused_anchors) const { | 1149 | std::vector<InDataAnchorPtr> ¬_fused_anchors) const { |
| 1147 | - std::queue<Path> path_queue; | 1150 | + std::queue<TransPath> path_queue; |
| 1148 | std::stack<OutDataAnchorPtr> out_anchor_stack; | 1151 | std::stack<OutDataAnchorPtr> out_anchor_stack; |
| 1149 | - if (head_next_type == NodeType::kWrapperNode) { | 1152 | + if (head_next_type == LinkNodeType::kWrapperNode) { |
| 1150 | GE_ASSERT_SUCCESS(GetRealInAnchorsForWrapperNode(in_anchor, out_anchor_stack)); | 1153 | GE_ASSERT_SUCCESS(GetRealInAnchorsForWrapperNode(in_anchor, out_anchor_stack)); |
| 1151 | } else { | 1154 | } else { |
| 1152 | - GE_ASSERT_SUCCESS(GetRealInAnchorsForNetOutput(nullptr, in_anchor, Path(), out_anchor_stack)); | 1155 | + GE_ASSERT_SUCCESS(GetRealInAnchorsForNetOutput(nullptr, in_anchor, TransPath(), out_anchor_stack)); |
| 1153 | } | 1156 | } |
| 1154 | while (!out_anchor_stack.empty()) { | 1157 | while (!out_anchor_stack.empty()) { |
| 1155 | const auto cur_out_anchor = out_anchor_stack.top(); | 1158 | const auto cur_out_anchor = out_anchor_stack.top(); |
| @@ -1162,7 +1165,7 @@ graphStatus SameTransdataBreadthFusionPass::CollectFusedInAnchors( | |||
| 1162 | continue; | 1165 | continue; |
| 1163 | } | 1166 | } |
| 1164 | if (next_node->GetType() == NETOUTPUT) { | 1167 | if (next_node->GetType() == NETOUTPUT) { |
| 1165 | - GE_ASSERT_SUCCESS(GetRealInAnchorsForNetOutput(nullptr, cur_in_anchor, Path(), out_anchor_stack)); | 1168 | + GE_ASSERT_SUCCESS(GetRealInAnchorsForNetOutput(nullptr, cur_in_anchor, TransPath(), out_anchor_stack)); |
| 1166 | continue; | 1169 | continue; |
| 1167 | } | 1170 | } |
| 1168 | if (allowed_in_anchors.find(cur_in_anchor) == allowed_in_anchors.end()) { | 1171 | if (allowed_in_anchors.find(cur_in_anchor) == allowed_in_anchors.end()) { |
| @@ -1176,7 +1179,7 @@ graphStatus SameTransdataBreadthFusionPass::CollectFusedInAnchors( | |||
| 1176 | return GRAPH_SUCCESS; | 1179 | return GRAPH_SUCCESS; |
| 1177 | } | 1180 | } |
| 1178 | 1181 | ||
| 1179 | -graphStatus SameTransdataBreadthFusionPass::DeleteTransdata(const Path &path) const { | 1182 | +graphStatus SameTransdataBreadthFusionPass::DeleteTransdata(const TransPath &path) const { |
| 1180 | auto trans_in_anchor = path.back().in_anchor; | 1183 | auto trans_in_anchor = path.back().in_anchor; |
| 1181 | auto trans = trans_in_anchor->GetOwnerNode(); | 1184 | auto trans = trans_in_anchor->GetOwnerNode(); |
| 1182 | auto trans_out_anchor = path.back().in_anchor->GetPeerOutAnchor(); | 1185 | auto trans_out_anchor = path.back().in_anchor->GetPeerOutAnchor(); |
| @@ -18,12 +18,11 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | namespace ge { | 20 | namespace ge { |
| 21 | -namespace { | 21 | +enum class LinkNodeType { kData, kNetOutput, kWrapperNode, kCast, kTransdata, kOthers}; |
| 22 | -enum class NodeType { kData, kNetOutput, kWrapperNode, kCast, kTransdata, kOthers}; | 22 | +struct PathLinkNode { |
| 23 | -struct LinkNode { | ||
| 24 | InDataAnchorPtr in_anchor; | 23 | InDataAnchorPtr in_anchor; |
| 25 | OutDataAnchorPtr real_peer_out_anchor; | 24 | OutDataAnchorPtr real_peer_out_anchor; |
| 26 | - NodeType node_type; | 25 | + LinkNodeType node_type; |
| 27 | }; | 26 | }; |
| 28 | struct CompareInfo { | 27 | struct CompareInfo { |
| 29 | std::string stream_label; | 28 | std::string stream_label; |
| @@ -32,11 +31,10 @@ struct CompareInfo { | |||
| 32 | ConstGeTensorDescPtr output_tensor_desc; | 31 | ConstGeTensorDescPtr output_tensor_desc; |
| 33 | }; | 32 | }; |
| 34 | 33 | ||
| 35 | -using Path = std::vector<LinkNode>; | 34 | +using TransPath = std::vector<PathLinkNode>; |
| 36 | -using Paths = std::vector<Path>; | 35 | +using TransPaths = std::vector<TransPath>; |
| 37 | using OrderedGraphToNodes = std::map<ComputeGraphPtr, std::map<uint32_t, NodePtr>, ComputeGraphCompareKey>; | 36 | using OrderedGraphToNodes = std::map<ComputeGraphPtr, std::map<uint32_t, NodePtr>, ComputeGraphCompareKey>; |
| 38 | using AnchorPairStack = std::stack<std::pair<OutDataAnchorPtr, OutDataAnchorPtr>>; | 37 | using AnchorPairStack = std::stack<std::pair<OutDataAnchorPtr, OutDataAnchorPtr>>; |
| 39 | -} | ||
| 40 | 38 | ||
| 41 | class SameTransdataBreadthFusionPass : public GraphPass { | 39 | class SameTransdataBreadthFusionPass : public GraphPass { |
| 42 | public: | 40 | public: |
| @@ -48,39 +46,41 @@ class SameTransdataBreadthFusionPass : public GraphPass { | |||
| 48 | graphStatus DoRun(ComputeGraphPtr graph); | 46 | graphStatus DoRun(ComputeGraphPtr graph); |
| 49 | graphStatus RunForNode(OutDataAnchorPtr &head_out_anchor); | 47 | graphStatus RunForNode(OutDataAnchorPtr &head_out_anchor); |
| 50 | 48 | ||
| 51 | - graphStatus GetPathsToTransdata(const OutDataAnchorPtr &head_out_anchor, Paths &paths) const; | 49 | + graphStatus GetPathsToTransdata(const OutDataAnchorPtr &head_out_anchor, TransPaths &paths) const; |
| 52 | graphStatus GetRealInAnchors(const OutDataAnchorPtr &real_out_anchor, | 50 | graphStatus GetRealInAnchors(const OutDataAnchorPtr &real_out_anchor, |
| 53 | const OutDataAnchorPtr &out_anchor, | 51 | const OutDataAnchorPtr &out_anchor, |
| 54 | - std::queue<Path> &path_queue, | 52 | + std::queue<TransPath> &path_queue, |
| 55 | - const Path &path) const; | 53 | + const TransPath &path) const; |
| 56 | graphStatus GetRealInAnchorsForWrapperNode( | 54 | graphStatus GetRealInAnchorsForWrapperNode( |
| 57 | const InDataAnchorPtr &in_anchor, std::stack<OutDataAnchorPtr> &out_anchor_stack) const; | 55 | const InDataAnchorPtr &in_anchor, std::stack<OutDataAnchorPtr> &out_anchor_stack) const; |
| 58 | graphStatus GetSubgraphDataOutAnchor(const ComputeGraphPtr &sub_graph, const int32_t wrapper_node_input_index, | 56 | graphStatus GetSubgraphDataOutAnchor(const ComputeGraphPtr &sub_graph, const int32_t wrapper_node_input_index, |
| 59 | OutDataAnchorPtr &data_out_anchor) const; | 57 | OutDataAnchorPtr &data_out_anchor) const; |
| 60 | graphStatus GetRealInAnchorsForNetOutput( | 58 | graphStatus GetRealInAnchorsForNetOutput( |
| 61 | - const OutDataAnchorPtr &real_out_anchor, const InDataAnchorPtr &in_anchor, const Path &path, | 59 | + const OutDataAnchorPtr &real_out_anchor, const InDataAnchorPtr &in_anchor, const TransPath &path, |
| 62 | std::stack<OutDataAnchorPtr> &out_anchor_stack) const; | 60 | std::stack<OutDataAnchorPtr> &out_anchor_stack) const; |
| 63 | - graphStatus FuseTransdata(Paths &paths); | 61 | + graphStatus FuseTransdata(TransPaths &paths); |
| 64 | - graphStatus GetSameTransdataPath(Paths &paths, std::vector<Paths> &same_transdata_paths_groups); | 62 | + graphStatus GetSameTransdataPath(TransPaths &paths, std::vector<TransPaths> &same_transdata_paths_groups); |
| 65 | - graphStatus RemoveUnSupportedPath(Paths &paths_with_same_transdata) const; | 63 | + graphStatus RemoveUnSupportedPath(TransPaths &paths_with_same_transdata) const; |
| 66 | - graphStatus GetCompareInfo(const Path &path, const LinkNode &link_node, CompareInfo &info); | 64 | + graphStatus GetCompareInfo(const TransPath &path, const PathLinkNode &link_node, CompareInfo &info); |
| 67 | - graphStatus UpdateTensorDesc(const Paths &paths_group, size_t keep_transdata_path_index); | 65 | + graphStatus UpdateTensorDesc(const TransPaths &paths_group, size_t keep_transdata_path_index); |
| 68 | graphStatus UpdateTensorDescForConnectData(const GeTensorDesc &trans_out_tensor_desc, | 66 | graphStatus UpdateTensorDescForConnectData(const GeTensorDesc &trans_out_tensor_desc, |
| 69 | - const LinkNode &link_node, std::stack<LinkNode> &link_node_stack) const; | 67 | + const PathLinkNode &link_node, |
| 68 | + std::stack<PathLinkNode> &link_node_stack) const; | ||
| 70 | graphStatus UpdateTensorDescForConnectWrapper(const GeTensorDesc &trans_out_tensor_desc, | 69 | graphStatus UpdateTensorDescForConnectWrapper(const GeTensorDesc &trans_out_tensor_desc, |
| 71 | - const LinkNode &link_node, std::stack<LinkNode> &link_node_stack); | 70 | + const PathLinkNode &link_node, |
| 71 | + std::stack<PathLinkNode> &link_node_stack); | ||
| 72 | graphStatus UpdateTensorDescForDiffGraph(const GeTensorDesc &trans_out_tensor_desc, | 72 | graphStatus UpdateTensorDescForDiffGraph(const GeTensorDesc &trans_out_tensor_desc, |
| 73 | - const LinkNode &link_node); | 73 | + const PathLinkNode &link_node); |
| 74 | - graphStatus ExtractTransdata(const Paths &paths_group, size_t keep_transdata_path_index) const; | 74 | + graphStatus ExtractTransdata(const TransPaths &paths_group, size_t keep_transdata_path_index) const; |
| 75 | 75 | ||
| 76 | graphStatus CollectFusedInAnchors(const InDataAnchorPtr &in_anchor, | 76 | graphStatus CollectFusedInAnchors(const InDataAnchorPtr &in_anchor, |
| 77 | const std::set<InDataAnchorPtr> &allowed_in_anchors, | 77 | const std::set<InDataAnchorPtr> &allowed_in_anchors, |
| 78 | - const NodeType head_next_type, | 78 | + const LinkNodeType head_next_type, |
| 79 | std::vector<InDataAnchorPtr> &fused_anchors, | 79 | std::vector<InDataAnchorPtr> &fused_anchors, |
| 80 | std::vector<InDataAnchorPtr> ¬_fused_anchors) const; | 80 | std::vector<InDataAnchorPtr> ¬_fused_anchors) const; |
| 81 | - graphStatus LinkHeadToTransdata(const Paths &paths_group, | 81 | + graphStatus LinkHeadToTransdata(const TransPaths &paths_group, |
| 82 | size_t keep_transdata_path_index) const; | 82 | size_t keep_transdata_path_index) const; |
| 83 | - graphStatus DeleteTransdata(const Path &path) const; | 83 | + graphStatus DeleteTransdata(const TransPath &path) const; |
| 84 | graphStatus AddNewPath(OutDataAnchorPtr &out_anchor, | 84 | graphStatus AddNewPath(OutDataAnchorPtr &out_anchor, |
| 85 | OutDataAnchorPtr &new_out_anchor, | 85 | OutDataAnchorPtr &new_out_anchor, |
| 86 | const std::set<InDataAnchorPtr> &allowed_in_anchors); | 86 | const std::set<InDataAnchorPtr> &allowed_in_anchors); |
| @@ -90,7 +90,7 @@ class SameTransdataBreadthFusionPass : public GraphPass { | |||
| 90 | graphStatus AddNewInputForNetOutput(InDataAnchorPtr &netout_in_anchor, | 90 | graphStatus AddNewInputForNetOutput(InDataAnchorPtr &netout_in_anchor, |
| 91 | std::vector<InDataAnchorPtr> &fused_anchors, | 91 | std::vector<InDataAnchorPtr> &fused_anchors, |
| 92 | AnchorPairStack &out_anchor_pair_stack) const; | 92 | AnchorPairStack &out_anchor_pair_stack) const; |
| 93 | - graphStatus AddNewPathToTransdataForDiffGraph(Paths &paths_group); | 93 | + graphStatus AddNewPathToTransdataForDiffGraph(TransPaths &paths_group); |
| 94 | 94 | ||
| 95 | void UpdateGraphNode(const ComputeGraphPtr &sub_graph, const uint32_t parent_index, NodePtr &node); | 95 | void UpdateGraphNode(const ComputeGraphPtr &sub_graph, const uint32_t parent_index, NodePtr &node); |
| 96 | 96 | ||
| @@ -1,12 +1,17 @@ | |||
| 1 | -/** | 1 | +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. |
| 2 | - * Copyright (c) 2025 Huawei Technologies Co., Ltd. | 2 | + |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +you may not use this file except in compliance with the License. |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | +You may obtain a copy of the License at |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + |
| 9 | - */ | 9 | +Unless required by applicable law or agreed to in writing, software |
| 10 | +distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | +See the License for the specific language governing permissions and | ||
| 13 | +limitations under the License. | ||
| 14 | +==============================================================================*/ | ||
| 10 | 15 | ||
| 11 | syntax = "proto3"; | 16 | syntax = "proto3"; |
| 12 | 17 | ||
| @@ -1,12 +1,17 @@ | |||
| 1 | -/** | 1 | +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. |
| 2 | - * Copyright (c) 2025 Huawei Technologies Co., Ltd. | 2 | + |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +you may not use this file except in compliance with the License. |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | +You may obtain a copy of the License at |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + |
| 9 | - */ | 9 | +Unless required by applicable law or agreed to in writing, software |
| 10 | +distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | +See the License for the specific language governing permissions and | ||
| 13 | +limitations under the License. | ||
| 14 | +==============================================================================*/ | ||
| 10 | 15 | ||
| 11 | syntax = "proto3"; | 16 | syntax = "proto3"; |
| 12 | 17 | ||
| @@ -1,12 +1,17 @@ | |||
| 1 | -/** | 1 | +/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. |
| 2 | - * Copyright (c) 2025 Huawei Technologies Co., Ltd. | 2 | + |
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +you may not use this file except in compliance with the License. |
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | +You may obtain a copy of the License at |
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | + |
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | 8 | + |
| 9 | - */ | 9 | +Unless required by applicable law or agreed to in writing, software |
| 10 | +distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | +See the License for the specific language governing permissions and | ||
| 13 | +limitations under the License. | ||
| 14 | +==============================================================================*/ | ||
| 10 | 15 | ||
| 11 | syntax = "proto3"; | 16 | syntax = "proto3"; |
| 12 | 17 | ||
| @@ -68,7 +68,9 @@ int32_t GenAscGraphAxisGroup(const ge::AscGraph &graph, optimize::autoschedule:: | |||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | bool CanMergeAxisGroup(const optimize::autoschedule::AxisGroup &lhs, const optimize::autoschedule::AxisGroup &rhs, | 70 | bool CanMergeAxisGroup(const optimize::autoschedule::AxisGroup &lhs, const optimize::autoschedule::AxisGroup &rhs, |
| 71 | - optimize::autoschedule::AxisGroup &merged_group) { | 71 | + optimize::autoschedule::AxisGroup &merged_group, const bool is_ge_call = false) { |
| 72 | + (void)rhs; | ||
| 73 | + (void)is_ge_call; | ||
| 72 | merged_group = lhs; | 74 | merged_group = lhs; |
| 73 | return true; | 75 | return true; |
| 74 | } | 76 | } |
| @@ -7,22 +7,19 @@ | |||
| 7 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | * See LICENSE in the root of the software repository for the full text of the License. | 8 | * See LICENSE in the root of the software repository for the full text of the License. |
| 9 | */ | 9 | */ |
| 10 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | 10 | ||
| 15 | 11 | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 16 | 15 | ||
| 17 | static std::string g_acl_stub_mock = ""; | 16 | static std::string g_acl_stub_mock = ""; |
| 18 | -static std::string g_acl_stub_mock_v2 = ""; | ||
| 19 | static char g_soc_version[50] = {0}; | 17 | static char g_soc_version[50] = {0}; |
| 20 | 18 | ||
| 21 | static int32_t g_free_stream_num = 2048; | 19 | static int32_t g_free_stream_num = 2048; |
| 22 | static int32_t g_free_event_num = 2048; | 20 | static int32_t g_free_event_num = 2048; |
| 23 | static int32_t g_cnt_rtStreamSynchronize_over_flow = 0; | 21 | static int32_t g_cnt_rtStreamSynchronize_over_flow = 0; |
| 24 | static int32_t g_cnt_rtStreamSynchronize_fail = 0; | 22 | static int32_t g_cnt_rtStreamSynchronize_fail = 0; |
| 25 | -static size_t reserve_mem_size_ = 200UL * 1024UL * 1024UL; | ||
| 26 | 23 | ||
| 27 | 24 | ||
| 28 | 25 | ||
| @@ -371,7 +368,7 @@ aclError AclRuntimeStub::aclrtMemcpyAsync(void *dst, | |||
| 371 | size_t remain_size = src_count; | 368 | size_t remain_size = src_count; |
| 372 | do { | 369 | do { |
| 373 | size_t copy_size = (remain_size > SECUREC_MEM_MAX_LEN) ? SECUREC_MEM_MAX_LEN : remain_size; | 370 | size_t copy_size = (remain_size > SECUREC_MEM_MAX_LEN) ? SECUREC_MEM_MAX_LEN : remain_size; |
| 374 | - memcpy_s((dst + offset), copy_size, (src + offset), copy_size); | 371 | + memcpy_s(ValueToPtr(PtrToValue(dst) + offset), copy_size, ValueToPtr(PtrToValue(src) + offset), copy_size); |
| 375 | offset += copy_size; | 372 | offset += copy_size; |
| 376 | remain_size -= copy_size; | 373 | remain_size -= copy_size; |
| 377 | } while (remain_size > 0U); | 374 | } while (remain_size > 0U); |
| @@ -28,7 +28,10 @@ pid_t ProcessUtils::Fork() { | |||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | int32_t ProcessUtils::Execute(const std::string &path, char *const *argv) { | 30 | int32_t ProcessUtils::Execute(const std::string &path, char *const *argv) { |
| 31 | - char *argv_stub[] = {"echo", "stub exec", NULL}; | 31 | + (void)path; |
| 32 | + (void)argv; | ||
| 33 | + char *argv_stub[] = {const_cast<char*>("echo"), | ||
| 34 | + const_cast<char*>("stub exec"), NULL}; | ||
| 32 | return execvp("echo", argv_stub); | 35 | return execvp("echo", argv_stub); |
| 33 | } | 36 | } |
| 34 | 37 | ||
| @@ -602,11 +602,25 @@ INT32 mmUnlink(const CHAR *filename) { | |||
| 602 | } | 602 | } |
| 603 | return unlink(filename); | 603 | return unlink(filename); |
| 604 | } | 604 | } |
| 605 | +INT32 mmSysSetEnv(mmEnvId id, const CHAR *value, INT32 overwrite) { | ||
| 606 | + (void)value; | ||
| 607 | + (void)overwrite; | ||
| 608 | + if (id == MM_ENV_AUTO_USE_UC_MEMORY) { | ||
| 609 | + return EN_OK; | ||
| 610 | + } | ||
| 611 | + return EN_INVALID_PARAM; | ||
| 612 | +} | ||
| 605 | 613 | ||
| 606 | INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite) { | 614 | INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite) { |
| 607 | if ((name == nullptr) || (value == nullptr)) { | 615 | if ((name == nullptr) || (value == nullptr)) { |
| 608 | return EN_INVALID_PARAM; | 616 | return EN_INVALID_PARAM; |
| 609 | } | 617 | } |
| 618 | + const std::set<std::string> ignore_env_set = {"ASCEND_LOG_SAVE_MODE", | ||
| 619 | + "ASCEND_HOSTPID", | ||
| 620 | + "LD_LIBRARY_PATH"}; | ||
| 621 | + if (ignore_env_set.find(name) != ignore_env_set.end()) { | ||
| 622 | + return EN_OK; | ||
| 623 | + } | ||
| 610 | return setenv(name, value, overwrite); | 624 | return setenv(name, value, overwrite); |
| 611 | } | 625 | } |
| 612 | 626 | ||
| @@ -29,7 +29,6 @@ ge::graphStatus InferShapeForAdd(InferShapeContext *context) { | |||
| 29 | auto output_shape = context->GetOutputShape(0); | 29 | auto output_shape = context->GetOutputShape(0); |
| 30 | if (input_shape_0.GetDimNum() != input_shape_1.GetDimNum()) { | 30 | if (input_shape_0.GetDimNum() != input_shape_1.GetDimNum()) { |
| 31 | auto min_num = std::min(input_shape_0.GetDimNum(), input_shape_1.GetDimNum()); | 31 | auto min_num = std::min(input_shape_0.GetDimNum(), input_shape_1.GetDimNum()); |
| 32 | - auto max_num = std::max(input_shape_0.GetDimNum(), input_shape_1.GetDimNum()); | ||
| 33 | if (min_num != 1) { | 32 | if (min_num != 1) { |
| 34 | GELOGE(ge::PARAM_INVALID, "Add param invalid, input_shape_0.GetDimNum() is %zu, input_shape_1.GetDimNum() is %zu", | 33 | GELOGE(ge::PARAM_INVALID, "Add param invalid, input_shape_0.GetDimNum() is %zu, input_shape_1.GetDimNum() is %zu", |
| 35 | input_shape_0.GetDimNum(), input_shape_1.GetDimNum()); | 34 | input_shape_0.GetDimNum(), input_shape_1.GetDimNum()); |
| @@ -15,7 +15,6 @@ using namespace gert; | |||
| 15 | namespace ops { | 15 | namespace ops { |
| 16 | ge::graphStatus InferShapeForAssign(InferShapeContext *context) { | 16 | ge::graphStatus InferShapeForAssign(InferShapeContext *context) { |
| 17 | GELOGD("InferShapeForAssign"); | 17 | GELOGD("InferShapeForAssign"); |
| 18 | - auto input_shape_0 = *context->GetInputShape(0); | ||
| 19 | auto input_shape_1 = *context->GetInputShape(1); | 18 | auto input_shape_1 = *context->GetInputShape(1); |
| 20 | auto output_shape = context->GetOutputShape(0); | 19 | auto output_shape = context->GetOutputShape(0); |
| 21 | *output_shape = input_shape_1; | 20 | *output_shape = input_shape_1; |
| @@ -54,7 +54,9 @@ TEST_F(GraphDslTest, test_build_graph_with_name) { | |||
| 54 | auto geGraph = ToGeGraph(g1); | 54 | auto geGraph = ToGeGraph(g1); |
| 55 | 55 | ||
| 56 | ASSERT_EQ(geGraph.GetAllNodes().size(), 2); | 56 | ASSERT_EQ(geGraph.GetAllNodes().size(), 2); |
| 57 | - ASSERT_EQ(geGraph.GetName(), "sample_graph"); | 57 | + AscendString get_name; |
| 58 | + geGraph.GetName(get_name); | ||
| 59 | + ASSERT_EQ(get_name.GetString(), "sample_graph"); | ||
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | TEST_F(GraphDslTest, test_build_from_from_op_desc_ptr) { | 62 | TEST_F(GraphDslTest, test_build_from_from_op_desc_ptr) { |
| @@ -51,18 +51,18 @@ void RegistOpToInfoStore(OpsKernelInfoStorePtr& info_store, const std::string& o | |||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | struct FakeOperator : Operator { | 53 | struct FakeOperator : Operator { |
| 54 | - FakeOperator(const std::string& op_type) : Operator(op_type) {} | 54 | + FakeOperator(const std::string& op_type) : Operator(op_type.c_str()) {} |
| 55 | 55 | ||
| 56 | FakeOperator& RegistInputs(const std::vector<std::string>& inputs) { | 56 | FakeOperator& RegistInputs(const std::vector<std::string>& inputs) { |
| 57 | for (auto& input : inputs) { | 57 | for (auto& input : inputs) { |
| 58 | - Operator::InputRegister(input); | 58 | + Operator::InputRegister(input.c_str()); |
| 59 | } | 59 | } |
| 60 | return *this; | 60 | return *this; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | FakeOperator& RegistOutputs(const std::vector<std::string>& outputs) { | 63 | FakeOperator& RegistOutputs(const std::vector<std::string>& outputs) { |
| 64 | for (auto& output : outputs) { | 64 | for (auto& output : outputs) { |
| 65 | - Operator::OutputRegister(output); | 65 | + Operator::OutputRegister(output.c_str()); |
| 66 | } | 66 | } |
| 67 | return *this; | 67 | return *this; |
| 68 | } | 68 | } |
| @@ -70,7 +70,7 @@ struct FakeOperator : Operator { | |||
| 70 | FakeOperator& AttrRegister(const std::map<std::string, std::variant<int64_t>>& attrs) { | 70 | FakeOperator& AttrRegister(const std::map<std::string, std::variant<int64_t>>& attrs) { |
| 71 | for (auto& attr : attrs) { | 71 | for (auto& attr : attrs) { |
| 72 | std::visit([this, name = attr.first](const auto& value) { | 72 | std::visit([this, name = attr.first](const auto& value) { |
| 73 | - Operator::AttrRegister(name, value); | 73 | + Operator::AttrRegister(name.c_str(), value); |
| 74 | }, attr.second); | 74 | }, attr.second); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -22,18 +22,17 @@ FAKE_NS_BEGIN | |||
| 22 | class GeRunningEvnFakerTest : public testing::Test { | 22 | class GeRunningEvnFakerTest : public testing::Test { |
| 23 | protected: | 23 | protected: |
| 24 | void SetUp() {} | 24 | void SetUp() {} |
| 25 | - OpsKernelManager &kernel_manager = OpsKernelManager::GetInstance(); | 25 | + OpsKernelManager &KernelManager() { return OpsKernelManager::GetInstance(); } |
| 26 | - OpsKernelBuilderManager &builder_manager = OpsKernelBuilderManager::Instance(); | 26 | + OpsKernelBuilderManager &BuilderManager() { return OpsKernelBuilderManager::Instance(); } |
| 27 | - DNNEngineManager &dnnengine_manager = DNNEngineManager::GetInstance(); | ||
| 28 | }; | 27 | }; |
| 29 | 28 | ||
| 30 | TEST_F(GeRunningEvnFakerTest, test_reset_running_env_is_success) { | 29 | TEST_F(GeRunningEvnFakerTest, test_reset_running_env_is_success) { |
| 31 | GeRunningEnvFaker ge_env; | 30 | GeRunningEnvFaker ge_env; |
| 32 | ge_env.Reset(); | 31 | ge_env.Reset(); |
| 33 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfoStores().size(), 0); | 32 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfoStores().size(), 0); |
| 34 | - ASSERT_EQ(builder_manager.GetAllOpsKernelBuilders().size(), 0); | 33 | + ASSERT_EQ(BuilderManager().GetAllOpsKernelBuilders().size(), 0); |
| 35 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfo().size(), 0); | 34 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfo().size(), 0); |
| 36 | - ASSERT_EQ(kernel_manager.GetOpsKernelInfo(SWITCH).size(), 0); | 35 | + ASSERT_EQ(KernelManager().GetOpsKernelInfo(SWITCH).size(), 0); |
| 37 | } | 36 | } |
| 38 | 37 | ||
| 39 | TEST_F(GeRunningEvnFakerTest, test_install_fake_op_success) { | 38 | TEST_F(GeRunningEvnFakerTest, test_install_fake_op_success) { |
| @@ -70,10 +69,10 @@ TEST_F(GeRunningEvnFakerTest, test_install_engine_with_default_info_store) { | |||
| 70 | GeRunningEnvFaker ge_env; | 69 | GeRunningEnvFaker ge_env; |
| 71 | ge_env.Install(FakeEngine("DNN_HCCL")); | 70 | ge_env.Install(FakeEngine("DNN_HCCL")); |
| 72 | 71 | ||
| 73 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfoStores().size(), 1); | 72 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfoStores().size(), 1); |
| 74 | - ASSERT_EQ(builder_manager.GetAllOpsKernelBuilders().size(), 1); | 73 | + ASSERT_EQ(BuilderManager().GetAllOpsKernelBuilders().size(), 1); |
| 75 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfo().size(), 0); | 74 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfo().size(), 0); |
| 76 | - ASSERT_EQ(kernel_manager.GetOpsKernelInfo(SWITCH).size(), 0); | 75 | + ASSERT_EQ(KernelManager().GetOpsKernelInfo(SWITCH).size(), 0); |
| 77 | } | 76 | } |
| 78 | 77 | ||
| 79 | TEST_F(GeRunningEvnFakerTest, test_install_engine_with_info_store_name) { | 78 | TEST_F(GeRunningEvnFakerTest, test_install_engine_with_info_store_name) { |
| @@ -81,10 +80,10 @@ TEST_F(GeRunningEvnFakerTest, test_install_engine_with_info_store_name) { | |||
| 81 | ge_env.Install(FakeEngine("DNN_HCCL").KernelInfoStore("AiCoreLib2")) | 80 | ge_env.Install(FakeEngine("DNN_HCCL").KernelInfoStore("AiCoreLib2")) |
| 82 | .Install(FakeOp(SWITCH).InfoStoreAndBuilder("AiCoreLib2")); | 81 | .Install(FakeOp(SWITCH).InfoStoreAndBuilder("AiCoreLib2")); |
| 83 | 82 | ||
| 84 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfoStores().size(), 1); | 83 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfoStores().size(), 1); |
| 85 | - ASSERT_EQ(builder_manager.GetAllOpsKernelBuilders().size(), 1); | 84 | + ASSERT_EQ(BuilderManager().GetAllOpsKernelBuilders().size(), 1); |
| 86 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfo().size(), 1); | 85 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfo().size(), 1); |
| 87 | - ASSERT_EQ(kernel_manager.GetOpsKernelInfo(SWITCH).size(), 1); | 86 | + ASSERT_EQ(KernelManager().GetOpsKernelInfo(SWITCH).size(), 1); |
| 88 | } | 87 | } |
| 89 | 88 | ||
| 90 | TEST_F(GeRunningEvnFakerTest, test_install_custom_kernel_builder_success) { | 89 | TEST_F(GeRunningEvnFakerTest, test_install_custom_kernel_builder_success) { |
| @@ -102,9 +101,9 @@ TEST_F(GeRunningEvnFakerTest, test_install_custom_kernel_builder_success) { | |||
| 102 | auto ai_core_kernel = FakeEngine("DNN_HCCL").KernelBuilder(std::make_shared<FakeKernelBuilder>()); | 101 | auto ai_core_kernel = FakeEngine("DNN_HCCL").KernelBuilder(std::make_shared<FakeKernelBuilder>()); |
| 103 | ge_env.Reset().Install(ai_core_kernel); | 102 | ge_env.Reset().Install(ai_core_kernel); |
| 104 | 103 | ||
| 105 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfoStores().size(), 1); | 104 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfoStores().size(), 1); |
| 106 | - ASSERT_EQ(builder_manager.GetAllOpsKernelBuilders().size(), 1); | 105 | + ASSERT_EQ(BuilderManager().GetAllOpsKernelBuilders().size(), 1); |
| 107 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfo().size(), 0); | 106 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfo().size(), 0); |
| 108 | } | 107 | } |
| 109 | 108 | ||
| 110 | TEST_F(GeRunningEvnFakerTest, test_install_custom_kernel_info_store_success) { | 109 | TEST_F(GeRunningEvnFakerTest, test_install_custom_kernel_info_store_success) { |
| @@ -118,36 +117,36 @@ TEST_F(GeRunningEvnFakerTest, test_install_custom_kernel_info_store_success) { | |||
| 118 | auto ai_core_kernel = FakeEngine("DNN_HCCL").KernelInfoStore(std::make_shared<FakeKernelBuilder>("AiCoreLib2")); | 117 | auto ai_core_kernel = FakeEngine("DNN_HCCL").KernelInfoStore(std::make_shared<FakeKernelBuilder>("AiCoreLib2")); |
| 119 | ge_env.Reset().Install(ai_core_kernel); | 118 | ge_env.Reset().Install(ai_core_kernel); |
| 120 | 119 | ||
| 121 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfoStores().size(),1); | 120 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfoStores().size(),1); |
| 122 | - ASSERT_EQ(builder_manager.GetAllOpsKernelBuilders().size(), 1); | 121 | + ASSERT_EQ(BuilderManager().GetAllOpsKernelBuilders().size(), 1); |
| 123 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfo().size(), 0); | 122 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfo().size(), 0); |
| 124 | } | 123 | } |
| 125 | 124 | ||
| 126 | TEST_F(GeRunningEvnFakerTest, test_install_default_fake_engine_success) { | 125 | TEST_F(GeRunningEvnFakerTest, test_install_default_fake_engine_success) { |
| 127 | GeRunningEnvFaker ge_env; | 126 | GeRunningEnvFaker ge_env; |
| 128 | ge_env.InstallDefault(); | 127 | ge_env.InstallDefault(); |
| 129 | 128 | ||
| 130 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfoStores().size(), 9); | 129 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfoStores().size(), 9); |
| 131 | - ASSERT_EQ(builder_manager.GetAllOpsKernelBuilders().size(), 9); | 130 | + ASSERT_EQ(BuilderManager().GetAllOpsKernelBuilders().size(), 9); |
| 132 | - ASSERT_GE(kernel_manager.GetAllOpsKernelInfo().size(), 49); | 131 | + ASSERT_GE(KernelManager().GetAllOpsKernelInfo().size(), 49); |
| 133 | } | 132 | } |
| 134 | 133 | ||
| 135 | TEST_F(GeRunningEvnFakerTest, test_install_fake_engine_with_optimizer_success) { | 134 | TEST_F(GeRunningEvnFakerTest, test_install_fake_engine_with_optimizer_success) { |
| 136 | GeRunningEnvFaker ge_env; | 135 | GeRunningEnvFaker ge_env; |
| 137 | ge_env.Install(FakeEngine("DNN_VM_AICPU")); | 136 | ge_env.Install(FakeEngine("DNN_VM_AICPU")); |
| 138 | 137 | ||
| 139 | - ASSERT_EQ(kernel_manager.GetAllOpsKernelInfoStores().size(), 1); | 138 | + ASSERT_EQ(KernelManager().GetAllOpsKernelInfoStores().size(), 1); |
| 140 | - ASSERT_EQ(kernel_manager.GetAllGraphOptimizerObjs().size(), 0); | 139 | + ASSERT_EQ(KernelManager().GetAllGraphOptimizerObjs().size(), 0); |
| 141 | - ASSERT_EQ(builder_manager.GetAllOpsKernelBuilders().size(), 1); | 140 | + ASSERT_EQ(BuilderManager().GetAllOpsKernelBuilders().size(), 1); |
| 142 | } | 141 | } |
| 143 | 142 | ||
| 144 | TEST_F(GeRunningEvnFakerTest, test_fake_graph_optimizer_success) { | 143 | TEST_F(GeRunningEvnFakerTest, test_fake_graph_optimizer_success) { |
| 145 | GeRunningEnvFaker ge_env; | 144 | GeRunningEnvFaker ge_env; |
| 146 | ge_env.Install(FakeEngine("DNN_VM_AICPU").GraphOptimizer("op1").GraphOptimizer("op2")); | 145 | ge_env.Install(FakeEngine("DNN_VM_AICPU").GraphOptimizer("op1").GraphOptimizer("op2")); |
| 147 | 146 | ||
| 148 | - ASSERT_EQ(kernel_manager.GetAllGraphOptimizerObjsByPriority().size(), 2); | 147 | + ASSERT_EQ(KernelManager().GetAllGraphOptimizerObjsByPriority().size(), 2); |
| 149 | - ASSERT_EQ(kernel_manager.GetAllGraphOptimizerObjsByPriority()[0].first, "op1"); | 148 | + ASSERT_EQ(KernelManager().GetAllGraphOptimizerObjsByPriority()[0].first, "op1"); |
| 150 | - ASSERT_EQ(kernel_manager.GetAllGraphOptimizerObjsByPriority()[1].first, "op2"); | 149 | + ASSERT_EQ(KernelManager().GetAllGraphOptimizerObjsByPriority()[1].first, "op2"); |
| 151 | - ASSERT_EQ(kernel_manager.GetAllGraphOptimizerObjs().size(), 2); | 150 | + ASSERT_EQ(KernelManager().GetAllGraphOptimizerObjs().size(), 2); |
| 152 | } | 151 | } |
| 153 | FAKE_NS_END | 152 | FAKE_NS_END |
| @@ -16,7 +16,7 @@ namespace ge { | |||
| 16 | class PathUtils { | 16 | class PathUtils { |
| 17 | public: | 17 | public: |
| 18 | static std::string Join(const std::vector<std::string> &names); | 18 | static std::string Join(const std::vector<std::string> &names); |
| 19 | - static bool CopyFile(const std::string &src, const std::string &dst); | 19 | + static void CopyFile(const std::string &src, const std::string &dst); |
| 20 | static int64_t RemoveDirectories(const std::string &path); | 20 | static int64_t RemoveDirectories(const std::string &path); |
| 21 | }; | 21 | }; |
| 22 | } | 22 | } |
| @@ -14,11 +14,11 @@ | |||
| 14 | namespace gert { | 14 | namespace gert { |
| 15 | 15 | ||
| 16 | AiCoreTaskDefFaker::AiCoreTaskDefFaker(std::string stub_name) : with_handle_(false), need_atomic_(false), | 16 | AiCoreTaskDefFaker::AiCoreTaskDefFaker(std::string stub_name) : with_handle_(false), need_atomic_(false), |
| 17 | - inited_(false), stub_name_(stub_name), with_aicpu_(false) { | 17 | + with_aicpu_(false), inited_(false), stub_name_(stub_name) { |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | AiCoreTaskDefFaker::AiCoreTaskDefFaker(bool with_handle, bool need_atomic, std::string stub_name, bool with_aicpu) | 20 | AiCoreTaskDefFaker::AiCoreTaskDefFaker(bool with_handle, bool need_atomic, std::string stub_name, bool with_aicpu) |
| 21 | - : with_handle_(with_handle), need_atomic_(need_atomic), inited_(false), stub_name_(stub_name), with_aicpu_(with_aicpu) { | 21 | + : with_handle_(with_handle), need_atomic_(need_atomic), with_aicpu_(with_aicpu), inited_(false), stub_name_(stub_name) { |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | vector<domi::TaskDef> AiCoreTaskDefFaker::CreateTaskDef(uint64_t op_index) { | 24 | vector<domi::TaskDef> AiCoreTaskDefFaker::CreateTaskDef(uint64_t op_index) { |
| @@ -27,7 +27,7 @@ void AppendShape(aicpu::FWKAdapter::FWKTaskExtInfoType type, size_t shape_num, s | |||
| 27 | aicpu_ext_info->infoType = type; | 27 | aicpu_ext_info->infoType = type; |
| 28 | aicpu_ext_info->infoLen = sizeof(AicpuShapeAndType) * shape_num; | 28 | aicpu_ext_info->infoLen = sizeof(AicpuShapeAndType) * shape_num; |
| 29 | AicpuShapeAndType input_shape_and_types[shape_num]; | 29 | AicpuShapeAndType input_shape_and_types[shape_num]; |
| 30 | - for (auto m = 0; m < shape_num; m++) { | 30 | + for (size_t m = 0U; m < shape_num; m++) { |
| 31 | input_shape_and_types[m].dims[0] = 5; | 31 | input_shape_and_types[m].dims[0] = 5; |
| 32 | } | 32 | } |
| 33 | memcpy_s(aicpu_ext_info->infoMsg, sizeof(AicpuShapeAndType) * shape_num, | 33 | memcpy_s(aicpu_ext_info->infoMsg, sizeof(AicpuShapeAndType) * shape_num, |
| @@ -15,7 +15,7 @@ using namespace std; | |||
| 15 | 15 | ||
| 16 | namespace ge { | 16 | namespace ge { |
| 17 | GetAllSwitchArgs::GetAllSwitchArgs(void *ptr, void *value_ptr, std::unique_ptr<std::string> tag) : | 17 | GetAllSwitchArgs::GetAllSwitchArgs(void *ptr, void *value_ptr, std::unique_ptr<std::string> tag) : |
| 18 | - handle_(ptr), tag_name_(std::move(tag)) { | 18 | + tag_name_(std::move(tag)), handle_(ptr) { |
| 19 | size_t data_size = 2 * sizeof(void *); | 19 | size_t data_size = 2 * sizeof(void *); |
| 20 | args_holder_ = std::unique_ptr<uint8_t[]>(new (std::nothrow) uint8_t[data_size]()); | 20 | args_holder_ = std::unique_ptr<uint8_t[]>(new (std::nothrow) uint8_t[data_size]()); |
| 21 | uintptr_t *ptr_s = reinterpret_cast<uintptr_t *>(args_holder_.get()); | 21 | uintptr_t *ptr_s = reinterpret_cast<uintptr_t *>(args_holder_.get()); |
| @@ -14,11 +14,7 @@ | |||
| 14 | namespace gert { | 14 | namespace gert { |
| 15 | namespace { | 15 | namespace { |
| 16 | uint32_t RunHostCpuFuncStub(void *args) { | 16 | uint32_t RunHostCpuFuncStub(void *args) { |
| 17 | - auto *arg_base = reinterpret_cast<uint8_t *>(args); | 17 | + (void)args; |
| 18 | - auto io_addrs = reinterpret_cast<uintptr_t *>(arg_base + sizeof(aicpu::AicpuParamHead)); | ||
| 19 | - auto *input_0 = reinterpret_cast<int32_t *>(io_addrs[0]); | ||
| 20 | - auto *input_1 = reinterpret_cast<int32_t *>(io_addrs[1]); | ||
| 21 | - auto *output = reinterpret_cast<int32_t *>(io_addrs[2]); | ||
| 22 | return 0; | 18 | return 0; |
| 23 | } | 19 | } |
| 24 | } // namespace | 20 | } // namespace |
| @@ -26,7 +26,7 @@ namespace ge { | |||
| 26 | std::string ge::PathUtils::Join(const std::vector<std::string> &names) { | 26 | std::string ge::PathUtils::Join(const std::vector<std::string> &names) { |
| 27 | return StringUtils::Join(names.begin(), names.end(), "/"); | 27 | return StringUtils::Join(names.begin(), names.end(), "/"); |
| 28 | } | 28 | } |
| 29 | -bool PathUtils::CopyFile(const std::string &src, const std::string &dst) { | 29 | +void PathUtils::CopyFile(const std::string &src, const std::string &dst) { |
| 30 | std::ifstream src_file(src, std::ios::binary); | 30 | std::ifstream src_file(src, std::ios::binary); |
| 31 | std::ofstream dst_file(dst, std::ios::binary); | 31 | std::ofstream dst_file(dst, std::ios::binary); |
| 32 | dst_file << src_file.rdbuf(); | 32 | dst_file << src_file.rdbuf(); |
| @@ -246,7 +246,7 @@ INT32 mmGetErrorCode() | |||
| 246 | INT32 mmIsDir(const CHAR *fileName) | 246 | INT32 mmIsDir(const CHAR *fileName) |
| 247 | { | 247 | { |
| 248 | struct stat fileStat; | 248 | struct stat fileStat; |
| 249 | - memset(&fileStat, sizeof(fileStat), 0); | 249 | + memset(&fileStat, 0, sizeof(fileStat)); |
| 250 | int32_t ret = lstat(fileName, &fileStat); | 250 | int32_t ret = lstat(fileName, &fileStat); |
| 251 | if (ret < 0) { | 251 | if (ret < 0) { |
| 252 | return -1; | 252 | return -1; |
| @@ -269,7 +269,7 @@ INT32 mmDlclose(VOID *handle) | |||
| 269 | 269 | ||
| 270 | CHAR *mmDlerror() | 270 | CHAR *mmDlerror() |
| 271 | { | 271 | { |
| 272 | - return ""; | 272 | + return nullptr; |
| 273 | } | 273 | } |
| 274 | 274 | ||
| 275 | INT32 mmDladdr(VOID *addr, mmDlInfo *info) | 275 | INT32 mmDladdr(VOID *addr, mmDlInfo *info) |
| @@ -328,7 +328,8 @@ static Status ParseParamByOpFuncStub(const ge::Operator &op_src, ge::Operator& o | |||
| 328 | return SUCCESS; | 328 | return SUCCESS; |
| 329 | } | 329 | } |
| 330 | 330 | ||
| 331 | -static Status ParseSubgraphPostFnIfStub(const std::string& subgraph_name, const ge::Graph& graph) { | 331 | +static Status ParseSubgraphPostFnIfStub(const AscendString& subgraph_name, const ge::Graph& graph) { |
| 332 | + (void)subgraph_name; | ||
| 332 | domi::AutoMappingSubgraphIOIndexFunc auto_mapping_subgraph_index_func = | 333 | domi::AutoMappingSubgraphIOIndexFunc auto_mapping_subgraph_index_func = |
| 333 | domi::FrameworkRegistry::Instance().GetAutoMappingSubgraphIOIndexFunc(domi::ONNX); | 334 | domi::FrameworkRegistry::Instance().GetAutoMappingSubgraphIOIndexFunc(domi::ONNX); |
| 334 | if (auto_mapping_subgraph_index_func == nullptr) { | 335 | if (auto_mapping_subgraph_index_func == nullptr) { |
| @@ -388,11 +389,11 @@ REGISTER_CUSTOM_OP("Conv2D") | |||
| 388 | 389 | ||
| 389 | REGISTER_CUSTOM_OP("If") | 390 | REGISTER_CUSTOM_OP("If") |
| 390 | .FrameworkType(domi::ONNX) | 391 | .FrameworkType(domi::ONNX) |
| 391 | - .OriginOpType({"ai.onnx::9::If", | 392 | + .OriginOpType({AscendString("ai.onnx::9::If"), |
| 392 | - "ai.onnx::10::If", | 393 | + AscendString("ai.onnx::10::If"), |
| 393 | - "ai.onnx::11::If", | 394 | + AscendString("ai.onnx::11::If"), |
| 394 | - "ai.onnx::12::If", | 395 | + AscendString("ai.onnx::12::If"), |
| 395 | - "ai.onnx::13::If"}) | 396 | + AscendString("ai.onnx::13::If")}) |
| 396 | .ParseParamsFn(ParseParamsStub) | 397 | .ParseParamsFn(ParseParamsStub) |
| 397 | .ParseParamsByOperatorFn(ParseParamByOpFuncStub) | 398 | .ParseParamsByOperatorFn(ParseParamByOpFuncStub) |
| 398 | .ParseSubgraphPostFn(ParseSubgraphPostFnIfStub); | 399 | .ParseSubgraphPostFn(ParseSubgraphPostFnIfStub); |
| @@ -415,7 +416,7 @@ REGISTER_CUSTOM_OP("Add") | |||
| 415 | 416 | ||
| 416 | REGISTER_CUSTOM_OP("PartitionedCall") | 417 | REGISTER_CUSTOM_OP("PartitionedCall") |
| 417 | .FrameworkType(domi::ONNX) | 418 | .FrameworkType(domi::ONNX) |
| 418 | - .OriginOpType({"ai.onnx::9::Clip"}) | 419 | + .OriginOpType("ai.onnx::9::Clip") |
| 419 | .ParseParamsFn(ParseParamsClipV9Stub) | 420 | .ParseParamsFn(ParseParamsClipV9Stub) |
| 420 | .ParseOpToGraphFn(ParseOpToGraphClipV9Stub); | 421 | .ParseOpToGraphFn(ParseOpToGraphClipV9Stub); |
| 421 | 422 | ||
| @@ -294,7 +294,6 @@ TEST_F(STestCaffeParser, caffe_parser_ParseParamsForDummyData_test) | |||
| 294 | ret = caffe_parser.ParseParamsForDummyData(*lay, op); | 294 | ret = caffe_parser.ParseParamsForDummyData(*lay, op); |
| 295 | EXPECT_EQ(ret, FAILED); | 295 | EXPECT_EQ(ret, FAILED); |
| 296 | 296 | ||
| 297 | - domi::caffe::BlobShape* dummpShape = dummyData->add_shape(); | ||
| 298 | ret = caffe_parser.ParseParamsForDummyData(*lay, op); | 297 | ret = caffe_parser.ParseParamsForDummyData(*lay, op); |
| 299 | EXPECT_EQ(ret, SUCCESS); | 298 | EXPECT_EQ(ret, SUCCESS); |
| 300 | } | 299 | } |
| @@ -48,7 +48,8 @@ static Status ParseParamByOpFunc(const ge::Operator &op_src, ge::Operator& op_de | |||
| 48 | return SUCCESS; | 48 | return SUCCESS; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | -Status ParseSubgraphPostFnIf(const std::string& subgraph_name, const ge::Graph& graph) { | 51 | +Status ParseSubgraphPostFnIf(const AscendString& subgraph_name, const ge::Graph& graph) { |
| 52 | + (void)subgraph_name; | ||
| 52 | domi::AutoMappingSubgraphIOIndexFunc auto_mapping_subgraph_index_func = | 53 | domi::AutoMappingSubgraphIOIndexFunc auto_mapping_subgraph_index_func = |
| 53 | domi::FrameworkRegistry::Instance().GetAutoMappingSubgraphIOIndexFunc(domi::ONNX); | 54 | domi::FrameworkRegistry::Instance().GetAutoMappingSubgraphIOIndexFunc(domi::ONNX); |
| 54 | if (auto_mapping_subgraph_index_func == nullptr) { | 55 | if (auto_mapping_subgraph_index_func == nullptr) { |
| @@ -75,11 +76,11 @@ void STestOnnxParser::RegisterCustomOp() { | |||
| 75 | // register if op info to GE | 76 | // register if op info to GE |
| 76 | REGISTER_CUSTOM_OP("If") | 77 | REGISTER_CUSTOM_OP("If") |
| 77 | .FrameworkType(domi::ONNX) | 78 | .FrameworkType(domi::ONNX) |
| 78 | - .OriginOpType({"ai.onnx::9::If", | 79 | + .OriginOpType({AscendString("ai.onnx::9::If"), |
| 79 | - "ai.onnx::10::If", | 80 | + AscendString("ai.onnx::10::If"), |
| 80 | - "ai.onnx::11::If", | 81 | + AscendString("ai.onnx::11::If"), |
| 81 | - "ai.onnx::12::If", | 82 | + AscendString("ai.onnx::12::If"), |
| 82 | - "ai.onnx::13::If"}) | 83 | + AscendString("ai.onnx::13::If")}) |
| 83 | .ParseParamsFn(ParseParams) | 84 | .ParseParamsFn(ParseParams) |
| 84 | .ParseParamsByOperatorFn(ParseParamByOpFunc) | 85 | .ParseParamsByOperatorFn(ParseParamByOpFunc) |
| 85 | .ParseSubgraphPostFn(ParseSubgraphPostFnIf); | 86 | .ParseSubgraphPostFn(ParseSubgraphPostFnIf); |
| @@ -536,7 +536,7 @@ namespace { | |||
| 536 | fusion_rlt->InsertOutputs("scope_node_n", {1}); // scope output 1 | 536 | fusion_rlt->InsertOutputs("scope_node_n", {1}); // scope output 1 |
| 537 | 537 | ||
| 538 | fusion_rlt->SetType(ge::kScopeToMultiNodes); | 538 | fusion_rlt->SetType(ge::kScopeToMultiNodes); |
| 539 | - fusion_rlt->SetName(fusion_op_name); | 539 | + fusion_rlt->SetName(fusion_op_name.c_str()); |
| 540 | fusion_rlt->SetDescription("Description for fusion node"); | 540 | fusion_rlt->SetDescription("Description for fusion node"); |
| 541 | 541 | ||
| 542 | // Add inner nodes in sequence. | 542 | // Add inner nodes in sequence. |