From 84c00546be9dc1548f61909f648de91fc47527ac Mon Sep 17 00:00:00 2001 From: chengduo Date: Wed, 13 Mar 2019 21:43:28 -0500 Subject: [PATCH] Make timeline_py compatible (#16185) * make timeline.py compatible test=develop * Follow comment test=develop --- tools/timeline.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/timeline.py b/tools/timeline.py index 694ab1d50f..44c1c09b80 100644 --- a/tools/timeline.py +++ b/tools/timeline.py @@ -160,6 +160,8 @@ class Timeline(object): self._devices[(k, event.device_id, "GPUKernel")] = pid self._chrome_trace.emit_pid("%s:gpu:%d" % (k, event.device_id), pid) + if not hasattr(profile_pb, "mem_events"): + continue for mevent in profile_pb.mem_events: if mevent.place == profiler_pb2.MemEvent.CUDAPlace: if (k, mevent.device_id, "GPU") not in self._mem_devices: @@ -211,7 +213,7 @@ class Timeline(object): args = {'name': event.name} if event.memcopy.bytes > 0: args['mem_bytes'] = event.memcopy.bytes - if event.detail_info: + if hasattr(event, "detail_info") and event.detail_info: args['detail_info'] = event.detail_info # TODO(panyx0718): Chrome tracing only handles ms. However, some # ops takes micro-seconds. Hence, we keep the ns here. @@ -220,6 +222,8 @@ class Timeline(object): event.sub_device_id, 'Op', event.name, args) def _allocate_memory_event(self): + if not hasattr(profiler_pb2, "MemEvent"): + return place_to_str = { profiler_pb2.MemEvent.CPUPlace: "CPU", profiler_pb2.MemEvent.CUDAPlace: "GPU", -- GitLab