From ee13794ff4aca8ddcb3df660830c3edbd785d6c2 Mon Sep 17 00:00:00 2001 From: zilinzhu Date: Fri, 24 Apr 2020 17:24:58 +0800 Subject: [PATCH] substitute regex to match multi-line timeline_label --- tensorflow/python/client/timeline.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tensorflow/python/client/timeline.py b/tensorflow/python/client/timeline.py index db9e1a0cddf..5d02c25a0b5 100644 --- a/tensorflow/python/client/timeline.py +++ b/tensorflow/python/client/timeline.py @@ -400,9 +400,10 @@ class Timeline(object): def _parse_kernel_label(self, label, node_name): """Parses the fields in a node timeline label.""" # Expects labels of the form: retval (arg) detail @@annotation - match = re.match(r'.*@@(.*)\#id.*', label) - if match is not None: - node_name = match.group(1) + start = label.find("@@") + end = label.find("#") + if start >= 0 and end >= 0 and start + 2 < end: + node_name = label[start+2:end] # Node names should always have the form 'name:op'. fields = node_name.split(':') + ['unknown'] name, op = fields[:2]