def traced_run(fetches):
"""Runs fetches, dumps timeline files in current directory."""
global sess
assert sess
global timeline_counter
run_metadata = tf.RunMetadata()
root = os.getcwd()+"/data"
from tensorflow.python.client import timeline
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(root+"/timeline_%d.json"%(timeline_counter,), "w").write(ctf)
open(root+"/stepstats_%d.pbtxt"%(timeline_counter,), "w").write(str(
run_metadata.step_stats))
timeline_counter+=1
return results
评论列表
文章目录