我以前在Tensorflow 1.2中使用以下命令:
export TF_XLA_FLAGS='--dump_ir_before_passes=true --dump_temp_products_to=./tmp'
用于在Tensorflow中转储LLVM IR。但是,在Tensorflow 1.3中删除了此标志link_to_the_flag_definition的定义文件,我现在想知道如何获得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())
答案 0 :(得分:0)
我在这里https://github.com/tensorflow/tensorflow/issues/11462找到了标志function convertToOHLC(data) {
var parsedData = JSON.parse(data),
pointStart = parsedData[0].date,
range = [],
low,
high,
ranges = [],
dataOHLC = [],
interval = 60 * 1000;
parsedData.sort(function(a, b) {
return a.date - b.date
});
$.each(parsedData, function(i, el) {
if (pointStart + interval < el.date) {
ranges.push(range.slice());
range = [];
range.push(el);
pointStart = pointStart + interval;
} else {
range.push(el);
}
if (i === parsedData.length - 1) {
ranges.push(range);
}
});
$.each(ranges, function(i, range) {
low = range[0].price;
high = range[0].price;
$.each(range, function(i, el) {
low = Math.min(low, el.price);
high = Math.max(high, el.price);
});
dataOHLC.push({
x: range[0].date + 30 * 1000,
open: Number(range[0].price),
high: high,
low: low,
close: Number(range[range.length - 1].price)
});
});
return dataOHLC
}
。它是在Tensorflow 1.3中添加的。