def traced_run(fetches):
"""Runs fetches, dumps timeline files in current directory."""
from tensorflow.python.client import timeline
global timeline_counter
run_metadata = tf.RunMetadata()
results = sess.run(fetches,
options=run_options,
run_metadata=run_metadata);
tl = timeline.Timeline(step_stats=run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format(show_memory=True,
show_dataflow=False)
open("timeline_%d.json"%(timeline_counter,), "w").write(ctf)
open("stepstats_%d.pbtxt"%(timeline_counter,), "w").write(str(
run_metadata.step_stats))
timeline_counter+=1
return results
评论列表
文章目录