已合并
【质量加固】style: add const qualifiers in ascendc graph dumper #1810
mclll创建于 14 天前
【质量加固】style: add const qualifiers in ascendc graph dumper #1810
已合并
共 1 个文件变更+10-10
| @@ -45,7 +45,7 @@ static const std::map<ge::DataType, DtypeInfo> kDtypeInfoMap = { | |||
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | const DtypeInfo *GetDtypeInfo(ge::DataType dtype) { | 47 | const DtypeInfo *GetDtypeInfo(ge::DataType dtype) { |
| 48 | - auto it = kDtypeInfoMap.find(dtype); | 48 | + const auto it = kDtypeInfoMap.find(dtype); |
| 49 | if (it != kDtypeInfoMap.end()) { | 49 | if (it != kDtypeInfoMap.end()) { |
| 50 | return &it->second; | 50 | return &it->second; |
| 51 | } | 51 | } |
| @@ -126,7 +126,7 @@ static std::string GetTensorTypeStr(const af::AscGraph &graph, const af::AscTens | |||
| 126 | std::stringstream ss; | 126 | std::stringstream ss; |
| 127 | 127 | ||
| 128 | // 数据类型 - 使用简写类型名 | 128 | // 数据类型 - 使用简写类型名 |
| 129 | - auto dtype = attr.dtype; | 129 | + const auto dtype = attr.dtype; |
| 130 | std::string dtype_str; | 130 | std::string dtype_str; |
| 131 | const DtypeInfo *info = GetDtypeInfo(dtype); | 131 | const DtypeInfo *info = GetDtypeInfo(dtype); |
| 132 | if (info != nullptr) { | 132 | if (info != nullptr) { |
| @@ -141,24 +141,24 @@ static std::string GetTensorTypeStr(const af::AscGraph &graph, const af::AscTens | |||
| 141 | // 形状 | 141 | // 形状 |
| 142 | for (size_t i = 0; i < attr.axis.size(); ++i) { | 142 | for (size_t i = 0; i < attr.axis.size(); ++i) { |
| 143 | if (i > 0) ss << ","; | 143 | if (i > 0) ss << ","; |
| 144 | - auto axis_id = attr.axis[i]; | 144 | + const auto axis_id = attr.axis[i]; |
| 145 | 145 | ||
| 146 | // 如果是 repeats,输出大小 | 146 | // 如果是 repeats,输出大小 |
| 147 | if (i < attr.repeats.size()) { | 147 | if (i < attr.repeats.size()) { |
| 148 | - auto repeat = attr.repeats[i]; | 148 | + const auto repeat = attr.repeats[i]; |
| 149 | if (repeat.GetExprType() == af::ExprType::kExprConstantRation) { | 149 | if (repeat.GetExprType() == af::ExprType::kExprConstantRation) { |
| 150 | int64_t val = 0; | 150 | int64_t val = 0; |
| 151 | if (repeat.GetConstValue(val)) { | 151 | if (repeat.GetConstValue(val)) { |
| 152 | ss << val; | 152 | ss << val; |
| 153 | } else { | 153 | } else { |
| 154 | - auto it = axis_id_to_name.find(axis_id); | 154 | + const auto it = axis_id_to_name.find(axis_id); |
| 155 | ss << (it != axis_id_to_name.end() ? it->second : "axis") << "_size"; | 155 | ss << (it != axis_id_to_name.end() ? it->second : "axis") << "_size"; |
| 156 | } | 156 | } |
| 157 | } else { | 157 | } else { |
| 158 | ss << af::SymbolicUtils::ToString(repeat); | 158 | ss << af::SymbolicUtils::ToString(repeat); |
| 159 | } | 159 | } |
| 160 | } else { | 160 | } else { |
| 161 | - auto it = axis_id_to_name.find(axis_id); | 161 | + const auto it = axis_id_to_name.find(axis_id); |
| 162 | ss << (it != axis_id_to_name.end() ? it->second : "axis") << "_size"; | 162 | ss << (it != axis_id_to_name.end() ? it->second : "axis") << "_size"; |
| 163 | } | 163 | } |
| 164 | } | 164 | } |
| @@ -177,7 +177,7 @@ DumpContext BuildDumpContext(const ascir::Graph &graph) { | |||
| 177 | 177 | ||
| 178 | // 收集函数参数(data, workspace, output) | 178 | // 收集函数参数(data, workspace, output) |
| 179 | for (auto node : graph.GetAllNodes()) { | 179 | for (auto node : graph.GetAllNodes()) { |
| 180 | - auto node_type = node->GetType(); | 180 | + const auto node_type = node->GetType(); |
| 181 | if (node_type == NodeType::kData) { | 181 | if (node_type == NodeType::kData) { |
| 182 | if (!node->outputs().empty()) { | 182 | if (!node->outputs().empty()) { |
| 183 | auto &output_attr = node->outputs()[0]->attr; | 183 | auto &output_attr = node->outputs()[0]->attr; |
| @@ -237,16 +237,16 @@ std::vector<std::string> CollectInputNames(const ascir::Graph &graph, const af:: | |||
| 237 | std::vector<std::string> input_names; | 237 | std::vector<std::string> input_names; |
| 238 | 238 | ||
| 239 | for (uint32_t index = 0U; index < node->GetAllInDataAnchorsSize(); index++) { | 239 | for (uint32_t index = 0U; index < node->GetAllInDataAnchorsSize(); index++) { |
| 240 | - auto in_anchor = node->GetInDataAnchor(static_cast<int32_t>(index)); | 240 | + const auto in_anchor = node->GetInDataAnchor(static_cast<int32_t>(index)); |
| 241 | if (in_anchor == nullptr) { | 241 | if (in_anchor == nullptr) { |
| 242 | input_names.push_back("nil"); | 242 | input_names.push_back("nil"); |
| 243 | continue; | 243 | continue; |
| 244 | } | 244 | } |
| 245 | - auto peer_out_anchor = in_anchor->GetPeerOutAnchor(); | 245 | + const auto peer_out_anchor = in_anchor->GetPeerOutAnchor(); |
| 246 | if (peer_out_anchor == nullptr) { | 246 | if (peer_out_anchor == nullptr) { |
| 247 | input_names.push_back("nil"); | 247 | input_names.push_back("nil"); |
| 248 | } else { | 248 | } else { |
| 249 | - auto peer_name = peer_out_anchor->GetOwnerNode()->GetName(); | 249 | + const auto peer_name = peer_out_anchor->GetOwnerNode()->GetName(); |
| 250 | int32_t out_idx = peer_out_anchor->GetIdx(); | 250 | int32_t out_idx = peer_out_anchor->GetIdx(); |
| 251 | // 检查源节点是否有多个输出,如果有则显示索引 | 251 | // 检查源节点是否有多个输出,如果有则显示索引 |
| 252 | auto peer_node = peer_out_anchor->GetOwnerNodeBarePtr(); | 252 | auto peer_node = peer_out_anchor->GetOwnerNodeBarePtr(); |