def run(self, fetches, feed_dict=None, options=None, run_metadata=None):
# Make sure there is no disagreement doing this.
if options is not None:
if options.trace_level != self.profiler_options.trace_level: # pragma: no cover
raise ValueError(
'In profiler session. Inconsistent trace '
'level from run call') # pragma: no cover
self.profiler_options.update(options) # pragma: no cover
self.local_run_metadata = tf.RunMetadata()
output = super(TracerSession, self).run(
fetches, feed_dict=feed_dict,
options=self.profiler_options,
run_metadata=self.local_run_metadata)
trace_time = timeline.Timeline(self.local_run_metadata.step_stats)
ctf = trace_time.generate_chrome_trace_format()
with open(self._trace_filename(), 'w') as trace_file:
trace_file.write(ctf)
if self.each_time:
self.counter += 1
return output
评论列表
文章目录