Skip to content

Commit

Permalink
fix record event for operator type in new dygraph (#44582)
Browse files Browse the repository at this point in the history
* fix new dygraph record event for op

* update unit test
  • Loading branch information
rainyfly authored Jul 26, 2022
1 parent 9b662be commit 963163e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion paddle/fluid/eager/auto_code_generator/eager_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ static std::string GenerateGradNodeCreationContent(
"%s"
" {\n"
" paddle::platform::RecordEvent node_creation_record_event(\"%s\", "
"paddle::platform::TracerEventType::Operator, 1);\n"
"paddle::platform::TracerEventType::OperatorInner, 1);\n"
"%s"
" if(require_any_grad) {\n"
" VLOG(6) << \" Construct Grad for %s \"; \n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def FindParsingFunctionFromAttributeType(atype):


RECORD_EVENT_TEMPLATE = \
"paddle::platform::RecordEvent {}(\"{} {}\", paddle::platform::TracerEventType::Operator, 1);"
"paddle::platform::RecordEvent {}(\"{} {}\", paddle::platform::TracerEventType::UserDefined, 1);"


RETURN_INPLACE_PYOBJECT_TEMPLATE = \
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/eager/backward.cc
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ void Backward(
bool retain_graph) {
VLOG(3) << "Run in Backward";
paddle::platform::RecordEvent backward_record_event(
"backward", paddle::platform::TracerEventType::Operator, 1);
"backward", paddle::platform::TracerEventType::UserDefined, 1);
RunBackward(tensors, grad_tensors, retain_graph);
phi::autotune::AutoTuneStatus::Instance().Update();
}
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/platform/profiler/chrometracing_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ void ChromeTracingLogger::StartLog() {
std::string(
R"JSON(
{
"id": %d, "name": "%s", "totalGlobalMem": %u,
"id": %d, "name": "%s", "totalGlobalMem": %llu,
"computeMajor": %d, "computeMinor": %d,
"maxThreadsPerBlock": %d, "maxThreadsPerMultiprocessor": %d,
"regsPerBlock": %d, "regsPerMultiprocessor": %d, "warpSize": %d,
Expand Down Expand Up @@ -633,7 +633,7 @@ void ChromeTracingLogger::StartLog() {
std::string(
R"JSON(
{
"id": %d, "name": "%s", "totalGlobalMem": %u,
"id": %d, "name": "%s", "totalGlobalMem": %llu,
"computeMajor": %d, "computeMinor": %d,
"maxThreadsPerBlock": %d, "maxThreadsPerMultiprocessor": %d,
"regsPerBlock": %d, "regsPerMultiprocessor": %d, "warpSize": %d,
Expand Down
22 changes: 11 additions & 11 deletions python/paddle/fluid/tests/unittests/test_profiler_statistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def test_statistic_case1(self):
profiler.TracerEventType.Forward, 50, 110,
1000, 1001)

userdefined_node = HostPythonNode('Communication Time',
profiler.TracerEventType.UserDefined,
100, 110, 1000, 1001)
userdefined_node = HostPythonNode(
'Communication Time', profiler.TracerEventType.PythonUserDefined,
100, 110, 1000, 1001)

communication_node = HostPythonNode(
'Communication', profiler.TracerEventType.Communication, 105, 110,
Expand Down Expand Up @@ -209,7 +209,7 @@ def test_statistic_case1(self):
0, profiler.TracerEventType.Memcpy), 60)
self.assertEqual(
time_range_summary.get_cpu_range_sum(
profiler.TracerEventType.UserDefined), 25)
profiler.TracerEventType.UserDefined), 15)
self.assertEqual(
time_range_summary.get_cpu_range_sum(
profiler.TracerEventType.Communication), 5)
Expand Down Expand Up @@ -277,9 +277,9 @@ def test_statistic_case2(self):
profiler.TracerEventType.Forward, 50, 110,
1000, 1001)

userdefined_node = HostPythonNode('Communication Time',
profiler.TracerEventType.UserDefined,
100, 110, 1000, 1001)
userdefined_node = HostPythonNode(
'Communication Time', profiler.TracerEventType.PythonUserDefined,
100, 110, 1000, 1001)
allreduce_launchkernel0 = HostPythonNode(
'cudalaunchkernel', profiler.TracerEventType.CudaRuntime, 102, 104,
1000, 1001)
Expand Down Expand Up @@ -451,7 +451,7 @@ def test_statistic_case2(self):
0, profiler.TracerEventType.Memcpy), 60)
self.assertEqual(
time_range_summary.get_cpu_range_sum(
profiler.TracerEventType.UserDefined), 25)
profiler.TracerEventType.UserDefined), 15)
self.assertEqual(
time_range_summary.get_cpu_range_sum(
profiler.TracerEventType.Communication), 5)
Expand Down Expand Up @@ -518,9 +518,9 @@ def test_statistic_case3(self):
optimization_node = HostPythonNode(
'Optimization', profiler.TracerEventType.Optimization, 220, 300,
1000, 1001)
userdefined_node = HostPythonNode('Communication Time',
profiler.TracerEventType.UserDefined,
60, 70, 1000, 1001)
userdefined_node = HostPythonNode(
'Communication Time', profiler.TracerEventType.PythonUserDefined,
60, 70, 1000, 1001)

conv2d_node = HostPythonNode('conv2d',
profiler.TracerEventType.Operator, 25, 25,
Expand Down
3 changes: 2 additions & 1 deletion python/paddle/profiler/profiler_statistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,8 @@ def parse(self, nodetrees):
or 'memset' in host_statistic_node.name.lower():
self.add_memory_manipulation_item(host_statistic_node)
else:
self.add_userdefined_item(host_statistic_node)
if host_statistic_node.type == TracerEventType.PythonUserDefined:
self.add_userdefined_item(host_statistic_node)
self.add_kernel_item(host_statistic_nodes[0])

for threadid, root_statistic_node in node_statistic_trees.items():
Expand Down

0 comments on commit 963163e

Please sign in to comment.