From 1bc367859c6dc3c3ab17fad25198f9fb25132e2f Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 14 Nov 2017 15:33:12 -0800 Subject: A few profiler improvements. 1. Op view proto copy uses too much memory and time, optimized. 2. Add a hint to use "bazel-bin" instead of "bazel run" 3. Make proto string parsing explicit (seems no longer throwing error) PiperOrigin-RevId: 175745677 --- tensorflow/python/profiler/model_analyzer.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'tensorflow/python/profiler') diff --git a/tensorflow/python/profiler/model_analyzer.py b/tensorflow/python/profiler/model_analyzer.py index 040a489163..46a921c0a1 100644 --- a/tensorflow/python/profiler/model_analyzer.py +++ b/tensorflow/python/profiler/model_analyzer.py @@ -20,6 +20,8 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +import sys + import six from google.protobuf import message @@ -206,8 +208,8 @@ class Profiler(object): try: tfprof_node.ParseFromString( print_mdl.Profile('code'.encode('utf-8'), opts.SerializeToString())) - except message.DecodeError as _: - pass + except message.DecodeError as e: + sys.stderr.write('Cannot parse returned proto: %s.\n' % e) return tfprof_node def profile_operations(self, options): @@ -223,8 +225,8 @@ class Profiler(object): try: tfprof_node.ParseFromString( print_mdl.Profile('op'.encode('utf-8'), opts.SerializeToString())) - except message.DecodeError as _: - pass + except message.DecodeError as e: + sys.stderr.write('Cannot parse returned proto: %s.\n' % e) return tfprof_node def profile_name_scope(self, options): @@ -240,8 +242,8 @@ class Profiler(object): try: tfprof_node.ParseFromString( print_mdl.Profile('scope'.encode('utf-8'), opts.SerializeToString())) - except message.DecodeError as _: - pass + except message.DecodeError as e: + sys.stderr.write('Cannot parse returned proto: %s.\n' % e) return tfprof_node def profile_graph(self, options): @@ -257,8 +259,8 @@ class Profiler(object): try: tfprof_node.ParseFromString( print_mdl.Profile('graph'.encode('utf-8'), opts.SerializeToString())) - except message.DecodeError as _: - pass + except message.DecodeError as e: + sys.stderr.write('Cannot parse returned proto: %s.\n' % e) return tfprof_node def advise(self, options): @@ -331,9 +333,8 @@ def profile(graph, opts.SerializeToString()) try: tfprof_node.ParseFromString(ret) - except message.DecodeError as _: - pass - # sys.stderr.write('Cannot parse returned proto: %s.\n' % e) + except message.DecodeError as e: + sys.stderr.write('Cannot parse returned proto: %s.\n' % e) elif cmd == 'graph' or cmd == 'scope': tfprof_node = tfprof_output_pb2.GraphNodeProto() @@ -345,9 +346,8 @@ def profile(graph, opts.SerializeToString()) try: tfprof_node.ParseFromString(ret) - except message.DecodeError as _: - pass - # sys.stderr.write('Cannot parse returned proto: %s.\n' % e) + except message.DecodeError as e: + sys.stderr.write('Cannot parse returned proto: %s.\n' % e) else: raise errors.InvalidArgumentError( None, None, 'unknown cmd: %s\n' % cmd) -- cgit v1.2.3