Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user_annotation event for dataloader and optimizer nodes #717

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tb_plugin/torch_tb_profiler/profiler/event_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def _parse_node(self,
EventTypes.OPERATOR,
EventTypes.PL_MODULE,
EventTypes.PROFILER_STEP,
EventTypes.MODULE]:
EventTypes.MODULE,
EventTypes.USER_ANNOTATION]:
if event.type == EventTypes.PROFILER_STEP:
op_node = ProfilerStepNode.create(event)
elif event.type == EventTypes.MODULE:
Expand All @@ -197,7 +198,8 @@ def _parse_node(self,
self.use_dp = True
if event.name == 'DistributedDataParallel.forward':
self.use_ddp = True
tid2list[int(tid)].append(op_node)
if op_node:
tid2list[int(tid)].append(op_node)
elif event.type == EventTypes.PL_PROFILE:
op_node = PLProfileNode.create(event)
pl_tid2list[int(tid)].append(op_node)
Expand Down Expand Up @@ -276,7 +278,7 @@ def _parse_step(self, event: DurationEvent, comm_nodes: Dict[int, CommunicationN
self.role_ranges[ProfileRole.Memset].append((ts, ts + dur))
elif evt_type == EventTypes.RUNTIME:
self.role_ranges[ProfileRole.Runtime].append((ts, ts + dur))
elif (evt_type == EventTypes.OPERATOR and (
elif ((evt_type == EventTypes.OPERATOR or evt_type == EventTypes.USER_ANNOTATION) and (
(event.name.startswith('enumerate(DataLoader)#') and event.name.endswith('.__next__'))
or event.name.startswith('enumerate(DataPipe)#'))):
self.role_ranges[ProfileRole.DataLoader].append((ts, ts + dur))
Expand Down
2 changes: 2 additions & 0 deletions tb_plugin/torch_tb_profiler/profiler/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ def create_operator_node(event: OperatorEvent):
return DataLoaderNode.create(event)
elif event.name.startswith('Optimizer.step'):
return OptimizerNode.create(event)
elif event.type == EventTypes.USER_ANNOTATION:
return None
else:
return OperatorNode.create(event)

Expand Down