我尝试了 tensorflow/examples/tutorials/mnist 下的示例并尝试应用 xla 来加速。但是,我不能像https://www.tensorflow.org/performance/xla/jit所说的那样看到 XlaLaunch。
此外,我尝试通过以下方式分析执行时间:
train_loops = 100000
t_start = time.time()
for i in range(train_loops):
batch_xs, batch_ys = mnist.train.next_batch(100)
# Create a timeline for the last loop and export to json to view with
# chrome://tracing/.
if i == train_loops - 1:
sess.run(train_step,
feed_dict={x: batch_xs,
y_: batch_ys},
options=tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE),
run_metadata=run_metadata)
trace = timeline.Timeline(step_stats=run_metadata.step_stats)
with open('timeline.ctf.json', 'w') as trace_file:
trace_file.write(trace.generate_chrome_trace_format())
else:
sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})
tdiff = time.time() - t_start
print("tdiff", tdiff, " i = ", i)
有和没有 xla 似乎没有区别。
我看到一些文章说我应该“重建” tensorflow 源以打开 xla?我是不是该?
有没有其他方法可以打开?或者它已默认打开,但我使用它的方式错误。
打开 xla 后,是否有基准来分析加速?
谢谢~