我正在编写一个启用了XLA的非常简单的tensorflow程序。基本上是这样的:
import tensorflow as tf
def ChainSoftMax(x, n)
tensor = tf.nn.softmax(x)
for i in range(n-1):
tensor = tf.nn.softmax(tensor)
return tensor
config = tf.ConfigProto()
config.graph_options.optimizer_options.global_jit_level = tf.OptimizerOptions.ON_1
input = tf.placeholder(tf.float32, [1000])
feed = np.random.rand(1000).astype('float32')
with tf.Session(config=config) as sess:
res = sess.run(ChainSoftMax(input, 2000), feed_dict={input: feed})基本上,我们的想法是看看XLA是否可以将softmax链融合在一起,以避免多次内核启动。在开启XLA的情况下,上面的程序几乎比没有XLA的机器上的GPU卡慢2倍。在我的图形处理器配置文件中,我看到XLA生成了许多名为"reduce_xxx“和"fusion_xxx”的内核,这些内核似乎压倒了整个运行时。有人知道这里发生了什么吗?
https://stackoverflow.com/questions/44523812
复制相似问题