未验证 提交 963163e6 编写于 作者: C chenjian 提交者: GitHub

fix record event for operator type in new dygraph (#44582)

* fix new dygraph record event for op

* update unit test
上级 9b662bef
...@@ -1386,7 +1386,7 @@ static std::string GenerateGradNodeCreationContent( ...@@ -1386,7 +1386,7 @@ static std::string GenerateGradNodeCreationContent(
"%s" "%s"
" {\n" " {\n"
" paddle::platform::RecordEvent node_creation_record_event(\"%s\", " " paddle::platform::RecordEvent node_creation_record_event(\"%s\", "
"paddle::platform::TracerEventType::Operator, 1);\n" "paddle::platform::TracerEventType::OperatorInner, 1);\n"
"%s" "%s"
" if(require_any_grad) {\n" " if(require_any_grad) {\n"
" VLOG(6) << \" Construct Grad for %s \"; \n" " VLOG(6) << \" Construct Grad for %s \"; \n"
......
...@@ -111,7 +111,7 @@ PARSE_PYTHON_C_ARGS_TEMPLATE = \ ...@@ -111,7 +111,7 @@ PARSE_PYTHON_C_ARGS_TEMPLATE = \
RECORD_EVENT_TEMPLATE = \ RECORD_EVENT_TEMPLATE = \
"paddle::platform::RecordEvent {}(\"{} {}\", paddle::platform::TracerEventType::Operator, 1);" "paddle::platform::RecordEvent {}(\"{} {}\", paddle::platform::TracerEventType::UserDefined, 1);"
RETURN_INPLACE_PYOBJECT_TEMPLATE = \ RETURN_INPLACE_PYOBJECT_TEMPLATE = \
......
...@@ -851,7 +851,7 @@ void Backward( ...@@ -851,7 +851,7 @@ void Backward(
bool retain_graph) { bool retain_graph) {
VLOG(3) << "Run in Backward"; VLOG(3) << "Run in Backward";
paddle::platform::RecordEvent backward_record_event( paddle::platform::RecordEvent backward_record_event(
"backward", paddle::platform::TracerEventType::Operator, 1); "backward", paddle::platform::TracerEventType::UserDefined, 1);
RunBackward(tensors, grad_tensors, retain_graph); RunBackward(tensors, grad_tensors, retain_graph);
phi::autotune::AutoTuneStatus::Instance().Update(); phi::autotune::AutoTuneStatus::Instance().Update();
} }
......
...@@ -603,7 +603,7 @@ void ChromeTracingLogger::StartLog() { ...@@ -603,7 +603,7 @@ void ChromeTracingLogger::StartLog() {
std::string( std::string(
R"JSON( R"JSON(
{ {
"id": %d, "name": "%s", "totalGlobalMem": %u, "id": %d, "name": "%s", "totalGlobalMem": %llu,
"computeMajor": %d, "computeMinor": %d, "computeMajor": %d, "computeMinor": %d,
"maxThreadsPerBlock": %d, "maxThreadsPerMultiprocessor": %d, "maxThreadsPerBlock": %d, "maxThreadsPerMultiprocessor": %d,
"regsPerBlock": %d, "regsPerMultiprocessor": %d, "warpSize": %d, "regsPerBlock": %d, "regsPerMultiprocessor": %d, "warpSize": %d,
...@@ -633,7 +633,7 @@ void ChromeTracingLogger::StartLog() { ...@@ -633,7 +633,7 @@ void ChromeTracingLogger::StartLog() {
std::string( std::string(
R"JSON( R"JSON(
{ {
"id": %d, "name": "%s", "totalGlobalMem": %u, "id": %d, "name": "%s", "totalGlobalMem": %llu,
"computeMajor": %d, "computeMinor": %d, "computeMajor": %d, "computeMinor": %d,
"maxThreadsPerBlock": %d, "maxThreadsPerMultiprocessor": %d, "maxThreadsPerBlock": %d, "maxThreadsPerMultiprocessor": %d,
"regsPerBlock": %d, "regsPerMultiprocessor": %d, "warpSize": %d, "regsPerBlock": %d, "regsPerMultiprocessor": %d, "warpSize": %d,
......
...@@ -82,8 +82,8 @@ class TestProfilerStatistic(unittest.TestCase): ...@@ -82,8 +82,8 @@ class TestProfilerStatistic(unittest.TestCase):
profiler.TracerEventType.Forward, 50, 110, profiler.TracerEventType.Forward, 50, 110,
1000, 1001) 1000, 1001)
userdefined_node = HostPythonNode('Communication Time', userdefined_node = HostPythonNode(
profiler.TracerEventType.UserDefined, 'Communication Time', profiler.TracerEventType.PythonUserDefined,
100, 110, 1000, 1001) 100, 110, 1000, 1001)
communication_node = HostPythonNode( communication_node = HostPythonNode(
...@@ -209,7 +209,7 @@ class TestProfilerStatistic(unittest.TestCase): ...@@ -209,7 +209,7 @@ class TestProfilerStatistic(unittest.TestCase):
0, profiler.TracerEventType.Memcpy), 60) 0, profiler.TracerEventType.Memcpy), 60)
self.assertEqual( self.assertEqual(
time_range_summary.get_cpu_range_sum( time_range_summary.get_cpu_range_sum(
profiler.TracerEventType.UserDefined), 25) profiler.TracerEventType.UserDefined), 15)
self.assertEqual( self.assertEqual(
time_range_summary.get_cpu_range_sum( time_range_summary.get_cpu_range_sum(
profiler.TracerEventType.Communication), 5) profiler.TracerEventType.Communication), 5)
...@@ -277,8 +277,8 @@ class TestProfilerStatistic(unittest.TestCase): ...@@ -277,8 +277,8 @@ class TestProfilerStatistic(unittest.TestCase):
profiler.TracerEventType.Forward, 50, 110, profiler.TracerEventType.Forward, 50, 110,
1000, 1001) 1000, 1001)
userdefined_node = HostPythonNode('Communication Time', userdefined_node = HostPythonNode(
profiler.TracerEventType.UserDefined, 'Communication Time', profiler.TracerEventType.PythonUserDefined,
100, 110, 1000, 1001) 100, 110, 1000, 1001)
allreduce_launchkernel0 = HostPythonNode( allreduce_launchkernel0 = HostPythonNode(
'cudalaunchkernel', profiler.TracerEventType.CudaRuntime, 102, 104, 'cudalaunchkernel', profiler.TracerEventType.CudaRuntime, 102, 104,
...@@ -451,7 +451,7 @@ class TestProfilerStatistic(unittest.TestCase): ...@@ -451,7 +451,7 @@ class TestProfilerStatistic(unittest.TestCase):
0, profiler.TracerEventType.Memcpy), 60) 0, profiler.TracerEventType.Memcpy), 60)
self.assertEqual( self.assertEqual(
time_range_summary.get_cpu_range_sum( time_range_summary.get_cpu_range_sum(
profiler.TracerEventType.UserDefined), 25) profiler.TracerEventType.UserDefined), 15)
self.assertEqual( self.assertEqual(
time_range_summary.get_cpu_range_sum( time_range_summary.get_cpu_range_sum(
profiler.TracerEventType.Communication), 5) profiler.TracerEventType.Communication), 5)
...@@ -518,8 +518,8 @@ class TestProfilerStatistic(unittest.TestCase): ...@@ -518,8 +518,8 @@ class TestProfilerStatistic(unittest.TestCase):
optimization_node = HostPythonNode( optimization_node = HostPythonNode(
'Optimization', profiler.TracerEventType.Optimization, 220, 300, 'Optimization', profiler.TracerEventType.Optimization, 220, 300,
1000, 1001) 1000, 1001)
userdefined_node = HostPythonNode('Communication Time', userdefined_node = HostPythonNode(
profiler.TracerEventType.UserDefined, 'Communication Time', profiler.TracerEventType.PythonUserDefined,
60, 70, 1000, 1001) 60, 70, 1000, 1001)
conv2d_node = HostPythonNode('conv2d', conv2d_node = HostPythonNode('conv2d',
......
...@@ -514,6 +514,7 @@ class EventSummary: ...@@ -514,6 +514,7 @@ class EventSummary:
or 'memset' in host_statistic_node.name.lower(): or 'memset' in host_statistic_node.name.lower():
self.add_memory_manipulation_item(host_statistic_node) self.add_memory_manipulation_item(host_statistic_node)
else: else:
if host_statistic_node.type == TracerEventType.PythonUserDefined:
self.add_userdefined_item(host_statistic_node) self.add_userdefined_item(host_statistic_node)
self.add_kernel_item(host_statistic_nodes[0]) self.add_kernel_item(host_statistic_nodes[0])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册