Open
CNN类推荐网络场景,当conv算子间存在较多elementwise算子,且GE图中存在较多transData时,可应用本融合pass,修改"向量岛"的格式为5hd来实现性能提升 #50
CNN类推荐网络场景,当conv算子间存在较多elementwise算子,且GE图中存在较多transData时,可应用本融合pass,修改"向量岛"的格式为5hd来实现性能提升 #50
Open
qlangAdd on 5 hours ago
Total: 4 files changed+1364-0
Afusion_pass/island_5hd_pass/CMakeLists.txt+37-0File content is under review, please try again later
Afusion_pass/island_5hd_pass/README.md+87-0File content is under review, please try again later
@@ -0,0 +1,71 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
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.
9+ */
10+ 
11+#ifndef __PASS_UTILS_H__
12+#define __PASS_UTILS_H__
13+ 
14+#include <initializer_list>
15+#include <string>
16+#include <vector>
17+#include "register/register_custom_pass.h"
18+ 
19+namespace pass_utils {
20+ 
21+inline bool IsNodeType(const ge::GNode& node, const char* type)
22+{
23+ ge::AscendString node_type;
24+ if (node.GetType(node_type) != ge::GRAPH_SUCCESS) {
25+ return false;
26+ }
27+ return node_type == type;
28+}
29+ 
30+inline bool IsAnyNodeType(const ge::GNode& node, std::initializer_list<const char*> types)
31+{
32+ for (const char* type : types) {
33+ if (IsNodeType(node, type)) {
34+ return true;
35+ }
36+ }
37+ return false;
38+}
39+ 
40+inline std::string GetNodeName(const ge::GNode& node)
41+{
42+ ge::AscendString name;
43+ node.GetName(name);
44+ return std::string(name.GetString());
45+}
46+ 
47+inline void RemoveAllInputEdges(ge::GraphPtr& graph, ge::GNode& node)
48+{
49+ for (size_t i = 0; i < node.GetInputsSize(); ++i) {
50+ auto [in_node, in_idx] = node.GetInDataNodesAndPortIndexs(static_cast<int32_t>(i));
51+ if (in_node != nullptr) {
52+ graph->RemoveEdge(*in_node, in_idx, node, static_cast<int32_t>(i));
53+ }
54+ }
55+}
56+ 
57+inline void RemoveAllOutputEdges(ge::GraphPtr& graph, ge::GNode& node)
58+{
59+ for (uint32_t out_idx = 0; out_idx < node.GetOutputsSize(); ++out_idx) {
60+ auto outs = node.GetOutDataNodesAndPortIndexs(out_idx);
61+ for (auto& [out_node, out_idx_of_consumer] : outs) {
62+ if (out_node != nullptr) {
63+ graph->RemoveEdge(node, static_cast<int32_t>(out_idx), *out_node, out_idx_of_consumer);
64+ }
65+ }
66+ }
67+}
68+ 
69+} // namespace pass_utils
70+ 
71+#endif // __PASS_UTILS_H__
Afusion_pass/island_5hd_pass/src/island_5hd_pass.cpp+1169-0File content is under review, please try again later