• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019-2021 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <algorithm>
18 #include "runtime/device/ascend/profiling/reporter/graph_desc_reporter.h"
19 #include "runtime/device/ascend/profiling/profiling_utils.h"
20 #include "backend/kernel_compiler/kernel.h"
21 #include "runtime/device/ascend/profiling/profiling_manager.h"
22 #include "backend/session/anf_runtime_algorithm.h"
23 #include "utils/ms_utils.h"
24 #include "utils/utils.h"
25 #include "runtime/device/ascend/profiling/reporter/task_desc_reporter.h"
26 #include "utils/ms_context.h"
27 #include "runtime/device/ascend/profiling/reporter/point_reporter.h"
28 #include "nlohmann/json.hpp"
29 #include "base/core_ops.h"
30 #include "profiler/device/profiling.h"
31 
32 namespace mindspore {
33 namespace device {
34 namespace ascend {
35 constexpr char kFpStartNode[] = "fp_point";
36 constexpr char kBpEndNode[] = "bp_point";
37 constexpr uint64_t kProfilingFpStartLogId = 2;
38 constexpr uint64_t kProfilingBpEndLogId = 3;
39 constexpr uint64_t kProfilingIterEndLogId = 4;
40 constexpr auto kDouble = 2;
41 
GetContextProfilingOption()42 nlohmann::json GetContextProfilingOption() {
43   auto profiler_manager = profiler::ProfilerManager::GetInstance();
44   MS_EXCEPTION_IF_NULL(profiler_manager);
45   const string prof_options_str = profiler_manager->GetProfilingOptions();
46   nlohmann::json j;
47   try {
48     j = nlohmann::json::parse(prof_options_str);
49   } catch (nlohmann::json::parse_error &e) {
50     MS_LOG(EXCEPTION) << "Parse profiling option json failed, error:" << e.what();
51   }
52   return j;
53 }
54 
GenerateProfilingTrace(const session::KernelGraph & kernel_graph)55 ProfilingTraceInfo ProfilingUtils::GenerateProfilingTrace(const session::KernelGraph &kernel_graph) {
56   MS_LOG(INFO) << "Profiling graph:" << kernel_graph.graph_id() << " Start to get trace";
57   custom_node_index_ = 5000;
58   auto &cnode_exec_order = kernel_graph.execution_order();
59   auto profiling_option = GetContextProfilingOption();
60 
61   ProfilingTraceInfo profiling_trace;
62   if (cnode_exec_order.empty()) {
63     return profiling_trace;
64   }
65   GetTraceBegin(kernel_graph, profiling_option, &profiling_trace);
66   GetTraceIterEnd(kernel_graph, &profiling_trace);
67   GetTraceBpEnd(kernel_graph, profiling_option, &profiling_trace);
68   GetTraceHccl(kernel_graph, NOT_NULL(&profiling_trace));
69 
70   auto set_string_converter = [](const std::set<std::string> &str_set) {
71     std::ostringstream stream;
72     stream << "(";
73     std::copy(str_set.begin(), str_set.end(), std::ostream_iterator<std::string>(stream, ","));
74     stream << ")";
75     return stream.str();
76   };
77 
78   MS_LOG(INFO) << "Profiling graph:" << kernel_graph.graph_id() << " trace_begin:" << profiling_trace.trace_begin
79                << " trace_bp_end:" << set_string_converter(profiling_trace.trace_bp_end)
80                << " trace_iter_end:" << set_string_converter(profiling_trace.trace_iter_end);
81   return profiling_trace;
82 }
83 
GetTraceHccl(const session::KernelGraph & kernel_graph,NotNull<ProfilingTraceInfo * > profiling_trace)84 void ProfilingUtils::GetTraceHccl(const session::KernelGraph &kernel_graph,
85                                   NotNull<ProfilingTraceInfo *> profiling_trace) {
86   for (const auto &node : kernel_graph.execution_order()) {
87     if (AnfAlgo::IsCommunicationOp(node)) {
88       MS_EXCEPTION_IF_NULL(node);
89       profiling_trace->trace_custom_node.insert(node->fullname_with_scope());
90       MS_LOG(INFO) << "Profiling graph:" << kernel_graph.graph_id() << " Get hccl node:" << node->fullname_with_scope();
91     }
92   }
93 }
94 
GetTraceBegin(const session::KernelGraph & kernel_graph,const nlohmann::json & option,ProfilingTraceInfo * trace_info)95 void ProfilingUtils::GetTraceBegin(const session::KernelGraph &kernel_graph, const nlohmann::json &option,
96                                    ProfilingTraceInfo *trace_info) {
97   MS_EXCEPTION_IF_NULL(trace_info);
98   auto &execution_orders = kernel_graph.execution_order();
99   auto iter = option.find(kFpStartNode);
100   if (iter != option.end() && iter->is_string()) {
101     std::string trace_begin_str = *iter;
102     if (!trace_begin_str.empty()) {
103       MS_LOG(INFO) << "Profiling graph:" << kernel_graph.graph_id()
104                    << " Get fp_point from profiling_option:" << trace_begin_str;
105       trace_info->trace_begin = trace_begin_str;
106       return;
107     }
108   }
109 
110   std::string fp_start_str;
111   std::set<std::string> getnext_outputs;
112   GetCNodeOutputRealNode(kGetNextOpName, kernel_graph, NOT_NULL(&getnext_outputs));
113   if (getnext_outputs.empty()) {
114     auto first_node = execution_orders.front();
115     MS_EXCEPTION_IF_NULL(first_node);
116     fp_start_str = first_node->fullname_with_scope();
117   } else {
118     for (auto &cnode : execution_orders) {
119       MS_EXCEPTION_IF_NULL(cnode);
120       if (getnext_outputs.count(cnode->fullname_with_scope()) != 0) {
121         fp_start_str = cnode->fullname_with_scope();
122         break;
123       }
124     }
125   }
126   trace_info->trace_begin = fp_start_str;
127 }
128 
GetCNodeOutputRealNode(const std::string & node_name,const session::KernelGraph & kernel_graph,NotNull<std::set<std::string> * > getnext_outputs)129 void ProfilingUtils::GetCNodeOutputRealNode(const std::string &node_name, const session::KernelGraph &kernel_graph,
130                                             NotNull<std::set<std::string> *> getnext_outputs) {
131   for (const auto &cnode : kernel_graph.execution_order()) {
132     MS_EXCEPTION_IF_NULL(cnode);
133     for (const auto &input : cnode->inputs()) {
134       auto prev_cnode = AnfAlgo::VisitKernel(input, 0);
135       MS_EXCEPTION_IF_NULL(prev_cnode.first);
136       if (!prev_cnode.first->isa<CNode>()) {
137         continue;
138       }
139       if (AnfAlgo::GetCNodeName(prev_cnode.first) == node_name) {
140         getnext_outputs->insert(cnode->fullname_with_scope());
141         MS_LOG(INFO) << "Profiling graph:" << kernel_graph.graph_id()
142                      << " Find GetNext Output CNode:" << cnode->fullname_with_scope();
143       }
144     }
145   }
146   if (getnext_outputs->empty()) {
147     MS_LOG(INFO) << "Profiling graph:" << kernel_graph.graph_id() << " GetNext not found";
148   }
149 }
150 
GetTraceBpEnd(const session::KernelGraph & kernel_graph,const nlohmann::json & option,ProfilingTraceInfo * trace_info)151 void ProfilingUtils::GetTraceBpEnd(const session::KernelGraph &kernel_graph, const nlohmann::json &option,
152                                    ProfilingTraceInfo *trace_info) {
153   MS_EXCEPTION_IF_NULL(trace_info);
154   auto bp_point = option.find(kBpEndNode);
155   if (bp_point != option.end() && bp_point->is_string()) {
156     std::string bp_point_str = *bp_point;
157     if (!bp_point_str.empty()) {
158       MS_LOG(INFO) << "Profiling graph:" << kernel_graph.graph_id()
159                    << " Get bp_point from profiling_option:" << bp_point_str;
160       trace_info->trace_bp_end.insert(bp_point_str);
161       return;
162     }
163   }
164 
165   std::string bp_end_str;
166   // Contain hccl kernel
167   auto &execution_orders = kernel_graph.execution_order();
168   auto iter = execution_orders.rbegin();
169   while (iter != execution_orders.rend()) {
170     if (AnfAlgo::IsCommunicationOp(*iter)) {
171       // store communication op input nodes' name
172       std::set<std::string> ar_input_node_names;
173       size_t input_num = AnfAlgo::GetInputTensorNum(*iter);
174       for (size_t i = 0; i < input_num; ++i) {
175         auto input_node_with_index = AnfAlgo::GetPrevNodeOutput(*iter, i);
176         auto input_node = input_node_with_index.first;
177         MS_EXCEPTION_IF_NULL(input_node);
178         ar_input_node_names.insert(input_node->fullname_with_scope());
179       }
180       // start from previous node
181       ++iter;
182       // find input names in previous node
183       while (iter != execution_orders.rend()) {
184         MS_EXCEPTION_IF_NULL(*iter);
185         if (ar_input_node_names.find((*iter)->fullname_with_scope()) != ar_input_node_names.end()) {
186           bp_end_str = (*iter)->fullname_with_scope();
187           break;
188         }
189         ++iter;
190       }
191       break;
192     }
193     ++iter;
194   }
195 
196   if (bp_end_str.empty()) {
197     trace_info->trace_bp_end = trace_info->trace_iter_end;
198   } else {
199     (void)trace_info->trace_bp_end.insert(bp_end_str);
200   }
201 }
202 
GetGraphLastKernelName(const session::KernelGraph & kernel_graph)203 std::string ProfilingUtils::GetGraphLastKernelName(const session::KernelGraph &kernel_graph) {
204   std::string last_tbe_kernel_name;
205   auto &execution_order = kernel_graph.execution_order();
206   // find last tbe_kernel
207   for (auto iter = execution_order.rbegin(); iter != execution_order.rend(); ++iter) {
208     MS_EXCEPTION_IF_NULL(*iter);
209     if (AnfAlgo::GetKernelType(*iter) == TBE_KERNEL || AnfAlgo::GetKernelType(*iter) == AKG_KERNEL ||
210         AnfAlgo::IsCommunicationOp(*iter)) {
211       last_tbe_kernel_name = (*iter)->fullname_with_scope();
212       break;
213     }
214   }
215   if (last_tbe_kernel_name.empty()) {
216     MS_LOG(WARNING) << "Profiling graph:" << kernel_graph.graph_id() << " No TBE or AKG or HCCL node found";
217   }
218   return last_tbe_kernel_name;
219 }
220 
GetTraceIterEnd(const session::KernelGraph & kernel_graph,ProfilingTraceInfo * trace_info)221 void ProfilingUtils::GetTraceIterEnd(const session::KernelGraph &kernel_graph, ProfilingTraceInfo *trace_info) {
222   MS_EXCEPTION_IF_NULL(trace_info);
223   // Find last execute node in control flow
224   auto &execution_orders = kernel_graph.execution_order();
225   for (auto &node : execution_orders) {
226     if (AnfAlgo::HasNodeAttr(kAttrProfilingIterEnd, node)) {
227       MS_LOG(INFO) << "Profiling graph:" << kernel_graph.graph_id()
228                    << " Found PROFILING_ITER_END:" << node->fullname_with_scope();
229       trace_info->trace_iter_end.insert(node->fullname_with_scope());
230     }
231   }
232 
233   if (!trace_info->trace_iter_end.empty()) {
234     return;
235   }
236 
237   MS_LOG(WARNING) << "Profiling graph:" << kernel_graph.graph_id()
238                   << " PROFILING_ITER_END not found. Found last TBE or Akg or Hccl op as PROFILING_ITER_END instead.";
239   auto last_kernel_name = GetGraphLastKernelName(kernel_graph);
240   if (last_kernel_name.empty()) {
241     MS_LOG(WARNING) << "Profiling graph:" << kernel_graph.graph_id() << " No TBE or AKG or HCCL op found in graph";
242   } else {
243     trace_info->trace_iter_end.insert(last_kernel_name);
244   }
245 }
246 
CreateProfilingCNode(const ProfilingContent & profiling_content,NotNull<session::KernelGraph * > graph_ptr)247 NotNull<CNodePtr> ProfilingUtils::CreateProfilingCNode(const ProfilingContent &profiling_content,
248                                                        NotNull<session::KernelGraph *> graph_ptr) {
249   kernel::KernelBuildInfo::KernelBuildInfoBuilder selected_kernel_builder;
250   selected_kernel_builder.SetInputsFormat({kOpFormat_DEFAULT, kOpFormat_DEFAULT});
251   selected_kernel_builder.SetInputsDeviceType({TypeId::kNumberTypeInt32, TypeId::kNumberTypeInt32});
252   selected_kernel_builder.SetFusionType(kernel::FusionType::OPAQUE);
253   selected_kernel_builder.SetProcessor(kernel::Processor::AICORE);
254   selected_kernel_builder.SetKernelType(KernelType::RT_KERNEL);
255   abstract::AbstractBasePtr type_none_abstract = std::make_shared<abstract::AbstractNone>();
256   auto primitive = std::make_shared<Primitive>(ProfilingUtils::kProfiling);
257   std::vector<AnfNodePtr> inputs;
258   inputs.emplace_back(NewValueNode(primitive));
259   CNodePtr cnode_ptr = graph_ptr->NewCNode(inputs);
260   MS_EXCEPTION_IF_NULL(cnode_ptr);
261   AnfAlgo::SetSelectKernelBuildInfo(selected_kernel_builder.Build(), cnode_ptr.get());
262   cnode_ptr->set_abstract(type_none_abstract);
263   // set attr
264   ValuePtr notify_value = MakeValue(profiling_content.notify);
265   ValuePtr trace_id_value = MakeValue(profiling_content.profiler_trace_id);
266   ValuePtr flags_value = MakeValue(profiling_content.flags);
267   AnfAlgo::SetNodeAttr(ProfilingUtils::kNotify, notify_value, cnode_ptr);
268   AnfAlgo::SetNodeAttr(ProfilingUtils::kProfilerTraceId, trace_id_value, cnode_ptr);
269   AnfAlgo::SetNodeAttr(ProfilingUtils::kFlags, flags_value, cnode_ptr);
270   return NOT_NULL(cnode_ptr);
271 }
272 
SaveProfilingPoint(uint32_t graph_id,const std::string & node_name,uint32_t point_id)273 void ProfilingUtils::SaveProfilingPoint(uint32_t graph_id, const std::string &node_name, uint32_t point_id) {
274   std::shared_ptr<ProfDesc> prof_desc_ptr = std::make_shared<PointDesc>(node_name, point_id);
275   auto iter = graph_point_.find(graph_id);
276   if (iter == graph_point_.end()) {
277     graph_point_.emplace(graph_id, std::vector<std::shared_ptr<ProfDesc>>{prof_desc_ptr});
278   } else {
279     iter->second.emplace_back(prof_desc_ptr);
280   }
281 }
282 
InsertProfilingTraceFp(const mindspore::AnfNodePtr & anf_node,const ProfilingTraceInfo & profiling_trace_info,NotNull<session::KernelGraph * > graph_ptr,NotNull<std::vector<mindspore::CNodePtr> * > kernel_list)283 void ProfilingUtils::InsertProfilingTraceFp(const mindspore::AnfNodePtr &anf_node,
284                                             const ProfilingTraceInfo &profiling_trace_info,
285                                             NotNull<session::KernelGraph *> graph_ptr,
286                                             NotNull<std::vector<mindspore::CNodePtr> *> kernel_list) {
287   MS_EXCEPTION_IF_NULL(anf_node);
288   if (profiling_trace_info.trace_begin == anf_node->fullname_with_scope()) {
289     MS_LOG(INFO) << "Profiling graph:" << graph_ptr->graph_id()
290                  << " Match FpStart:" << profiling_trace_info.trace_begin;
291     InsertProfilingTraceJobId(anf_node, graph_ptr, kernel_list);
292     ProfilingContent fp_profiling_content = {false, kProfilingFpStartLogId, 0};
293     auto fp_profiling_node = CreateProfilingCNodeWithStream(anf_node, fp_profiling_content, graph_ptr);
294     kernel_list->emplace_back(fp_profiling_node);
295     // insert ProfDesc
296     SaveProfilingPoint(graph_ptr->graph_id(), anf_node->fullname_with_scope(), kProfilingFpStartLogId);
297   }
298 }
299 
InsertProfilingTraceJobId(const AnfNodePtr & anf_node,NotNull<session::KernelGraph * > graph_ptr,NotNull<std::vector<CNodePtr> * > kernel_list)300 void ProfilingUtils::InsertProfilingTraceJobId(const AnfNodePtr &anf_node, NotNull<session::KernelGraph *> graph_ptr,
301                                                NotNull<std::vector<CNodePtr> *> kernel_list) {
302   auto job_id = ProfilingManager::GetInstance().GetJobId();
303   ProfilingContent job_profiling_context = {false, job_id, 0};
304   auto job_profiling_node = CreateProfilingCNodeWithStream(anf_node, job_profiling_context, graph_ptr);
305   kernel_list->emplace_back(job_profiling_node);
306 }
307 
CreateProfilingCNodeWithStream(const mindspore::AnfNodePtr & anf_node,const ProfilingContent & profiling_content,NotNull<session::KernelGraph * > graph_ptr)308 CNodePtr ProfilingUtils::CreateProfilingCNodeWithStream(const mindspore::AnfNodePtr &anf_node,
309                                                         const ProfilingContent &profiling_content,
310                                                         NotNull<session::KernelGraph *> graph_ptr) {
311   CNodePtr profiling_node = CreateProfilingCNode(profiling_content, graph_ptr);
312   AnfAlgo::SetStreamDistinctionLabel(AnfAlgo::GetStreamDistinctionLabel(anf_node.get()), profiling_node.get());
313   AnfAlgo::SetStreamId(AnfAlgo::GetStreamId(anf_node), profiling_node.get());
314   return profiling_node;
315 }
316 
InsertProfilingCustomOp(const AnfNodePtr & anf_node,const ProfilingTraceInfo & profiling_trace_info,NotNull<session::KernelGraph * > graph_ptr,NotNull<std::vector<CNodePtr> * > kernel_list)317 void ProfilingUtils::InsertProfilingCustomOp(const AnfNodePtr &anf_node, const ProfilingTraceInfo &profiling_trace_info,
318                                              NotNull<session::KernelGraph *> graph_ptr,
319                                              NotNull<std::vector<CNodePtr> *> kernel_list) {
320   MS_EXCEPTION_IF_NULL(anf_node);
321   auto iter = profiling_trace_info.trace_custom_node.find(anf_node->fullname_with_scope());
322   if (iter == profiling_trace_info.trace_custom_node.end()) {
323     return;
324   }
325   MS_LOG(INFO) << "Profiling graph:" << graph_ptr->graph_id() << " Match CustomOp:" << anf_node->fullname_with_scope();
326   // custom op profiling job start from 10000.
327   auto custom_point_id = kDouble * custom_node_index_;
328   ProfilingContent front_profiling_content = {false, custom_point_id, 0};
329   CNodePtr front_node = CreateProfilingCNodeWithStream(anf_node, front_profiling_content, graph_ptr);
330   kernel_list->insert(kernel_list->end() - 1, front_node);
331   SaveProfilingPoint(graph_ptr->graph_id(), anf_node->fullname_with_scope(), custom_point_id);
332 
333   ProfilingContent back_profiling_content = {false, custom_point_id + 1, 0};
334   CNodePtr back_node = CreateProfilingCNodeWithStream(anf_node, back_profiling_content, graph_ptr);
335   kernel_list->insert(kernel_list->end(), back_node);
336   SaveProfilingPoint(graph_ptr->graph_id(), anf_node->fullname_with_scope(), custom_point_id + 1);
337   ++custom_node_index_;
338 }
339 
InsertProfilingTraceBpEnd(const AnfNodePtr & anf_node,const ProfilingTraceInfo & profiling_trace_info,NotNull<session::KernelGraph * > graph_ptr,NotNull<std::vector<CNodePtr> * > kernel_list)340 void ProfilingUtils::InsertProfilingTraceBpEnd(const AnfNodePtr &anf_node,
341                                                const ProfilingTraceInfo &profiling_trace_info,
342                                                NotNull<session::KernelGraph *> graph_ptr,
343                                                NotNull<std::vector<CNodePtr> *> kernel_list) {
344   MS_EXCEPTION_IF_NULL(anf_node);
345   auto node_name = anf_node->fullname_with_scope();
346   if (profiling_trace_info.trace_bp_end.find(node_name) != profiling_trace_info.trace_bp_end.end()) {
347     MS_LOG(INFO) << "Profiling graph:" << graph_ptr->graph_id() << " Match BpEnd:" << node_name;
348     ProfilingContent bp_end_profiling_content = {false, kProfilingBpEndLogId, 0};
349     CNodePtr bp_end_node = CreateProfilingCNodeWithStream(anf_node, bp_end_profiling_content, graph_ptr);
350     kernel_list->emplace_back(bp_end_node);
351     SaveProfilingPoint(graph_ptr->graph_id(), node_name, kProfilingBpEndLogId);
352   }
353 }
354 
InsertProfilingTraceIterEnd(const AnfNodePtr & anf_node,const ProfilingTraceInfo & profiling_trace_info,NotNull<session::KernelGraph * > graph_ptr,NotNull<std::vector<mindspore::CNodePtr> * > kernel_list)355 void ProfilingUtils::InsertProfilingTraceIterEnd(const AnfNodePtr &anf_node,
356                                                  const ProfilingTraceInfo &profiling_trace_info,
357                                                  NotNull<session::KernelGraph *> graph_ptr,
358                                                  NotNull<std::vector<mindspore::CNodePtr> *> kernel_list) {
359   MS_EXCEPTION_IF_NULL(anf_node);
360   auto full_scope_name = anf_node->fullname_with_scope();
361   if (profiling_trace_info.trace_iter_end.find(full_scope_name) != profiling_trace_info.trace_iter_end.end()) {
362     MS_LOG(INFO) << "Profiling graph:" << graph_ptr->graph_id() << " Match IterEnd:" << full_scope_name;
363     ProfilingContent iter_end_profiling_content = {true, kProfilingIterEndLogId, 0};
364     auto iter_end_kernel_ptr = CreateProfilingCNodeWithStream(anf_node, iter_end_profiling_content, graph_ptr);
365     kernel_list->emplace_back(iter_end_kernel_ptr);
366     SaveProfilingPoint(graph_ptr->graph_id(), full_scope_name, kProfilingIterEndLogId);
367   }
368 }
369 
SetGraphKernelName(uint32_t graph_id,const std::vector<std::string> & kernel_names)370 void ProfilingUtils::SetGraphKernelName(uint32_t graph_id, const std::vector<std::string> &kernel_names) {
371   auto ret = graph_kernel_name_.try_emplace(graph_id, kernel_names);
372   if (!ret.second) {
373     MS_LOG(ERROR) << "[profiling]graph " << graph_id << " kernel names already exist";
374   }
375 }
376 
SetGraphProfilingCNode(uint32_t graph_id,const std::vector<CNodePtr> & profiling_cnode_list)377 void ProfilingUtils::SetGraphProfilingCNode(uint32_t graph_id, const std::vector<CNodePtr> &profiling_cnode_list) {
378   auto ret = graph_profiling_cnode_.try_emplace(graph_id, profiling_cnode_list);
379   if (!ret.second) {
380     MS_LOG(ERROR) << "[profiling]graph " << graph_id << " profiling cnode list already exist";
381   }
382 }
383 
ValidComputeGraph(const session::KernelGraph & kernel_graph)384 bool ProfilingUtils::ValidComputeGraph(const session::KernelGraph &kernel_graph) {
385   for (const auto &node : kernel_graph.execution_order()) {
386     if (AnfAlgo::GetKernelType(node) == TBE_KERNEL || AnfAlgo::GetKernelType(node) == AKG_KERNEL) {
387       return true;
388     }
389   }
390   return false;
391 }
392 
ReportProfilingData(const std::vector<uint32_t> & task_ids,const std::vector<uint32_t> & stream_ids,const session::KernelGraph & kernel_graph)393 void ProfilingUtils::ReportProfilingData(const std::vector<uint32_t> &task_ids, const std::vector<uint32_t> &stream_ids,
394                                          const session::KernelGraph &kernel_graph) {
395   if (!ValidComputeGraph(kernel_graph)) {
396     MS_LOG(INFO) << "Not a valid compute graph:" << kernel_graph.graph_id();
397     return;
398   }
399 
400   auto ret = graph_profiling_cnode_.find(kernel_graph.graph_id());
401   if (ret == graph_profiling_cnode_.end()) {
402     MS_LOG(ERROR) << "Graph id not found";
403     return;
404   }
405 
406   auto context = MsContext::GetInstance();
407   MS_EXCEPTION_IF_NULL(context);
408   TaskDescReporter task_reporter(context->get_param<uint32_t>(MS_CTX_DEVICE_ID), "vm_task_desc_info", ret->second);
409   task_reporter.set_task_ids(task_ids);
410   task_reporter.set_stream_ids(stream_ids);
411   task_reporter.ReportData();
412 
413   GraphDescReporter graph_reporter(context->get_param<uint32_t>(MS_CTX_DEVICE_ID), "vm_graph_desc_info", ret->second);
414   graph_profiling_cnode_.erase(ret);
415   graph_reporter.ReportData();
416 
417   // Report profiling point
418   auto point_iter = graph_point_.find(kernel_graph.graph_id());
419   if (point_iter == graph_point_.end()) {
420     MS_LOG(ERROR) << "Graph id not found in graph_point";
421     return;
422   }
423   PointReporter point_reporter(context->get_param<uint32_t>(MS_CTX_DEVICE_ID), "vm_point");
424   for (const auto &point : point_iter->second) {
425     point_reporter.AddReportData(point);
426   }
427   point_reporter.ReportData();
428 }
429 }  // namespace ascend
430 }  // namespace device
431 }  // namespace mindspore
432