0

我曾经在 Tensorflow 1.2 中使用以下命令:

export TF_XLA_FLAGS='--dump_ir_before_passes=true --dump_temp_products_to=./tmp'

用于在 Tensorflow 中转储 LLVM IR。但是,这个标志link_to_the_flag_definition的定义文件在 Tensorflow 1.3 中被删除了,我现在想知道如何获得 LLVM IR 转储?

为了您的方便,这里有一个测试文件:

import tensorflow as tf
import numpy as np
import os
from tensorflow.python.client import timeline
import json

run_metadata = tf.RunMetadata()
sess = tf.Session()
jit_scope = tf.contrib.compiler.jit.experimental_jit_scope
x = tf.placeholder(np.float32, shape=[1000000])
y = tf.placeholder(np.float32, shape=[1000000])
c = tf.constant(0.1)

with jit_scope():
  z = tf.add(tf.scalar_mul(0.1,x), y)
  ix = np.ones((1000000), dtype=np.float32)
  iy = np.ones((1000000), dtype=np.float32)
  sess.run(z,
           feed_dict={x: ix, y: iy},
           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())
4

1 回答 1

0

我在--xla_dump_ir_to这里找到了标志:https ://github.com/tensorflow/tensorflow/issues/11462 。它是在 TensorFlow 1.3 中添加的。

于 2018-08-13T14:12:57.730 回答