1

我正在尝试使用 XLA 通过 JIT 编译运行我的 Tensorflow 程序。我想了解它产生的编译计算图。但是,当它无法运行时,使用:

env "TF_XLA_FLAGS=--xla_generate_hlo_graph=.*" python Genetic\ Algorithm\ in\ Tensorflow-Part\ 2.py
2017-06-10 16:22:45.577462: I tensorflow/compiler/xla/service/platform_util.cc:58] platform Host present with 8 visible devices
2017-06-10 16:22:45.578014: I tensorflow/compiler/xla/service/service.cc:183] XLA service 0x7fb80bb1e800 executing computations on platform Host. Devices:
2017-06-10 16:22:45.578038: I tensorflow/compiler/xla/service/service.cc:191]   StreamExecutor device (0): <undefined>, <undefined>
2017-06-10 16:22:45.608555: I tensorflow/compiler/xla/service/hlo_graph_dumper.cc:454] computation cluster_28[_XlaCompiledKernel=true,_XlaNumConstantArgs=0,_XlaNumResourceArgs=0].v5 [CPU: pipeline start, before convolution-canonicalization]: /tmp/hlo_graph_0.9QsDAz.dot
2017-06-10 16:22:45.608686: I tensorflow/compiler/xla/service/hlo_graph_dumper.cc:454] computation cluster_31[_XlaCompiledKernel=true,_XlaNumConstantArgs=0,_XlaNumResourceArgs=0].v5 [CPU: pipeline start, before convolution-canonicalization]: /tmp/hlo_graph_1.wVNyt7.dot
2017-06-10 16:22:45.608872: I tensorflow/compiler/xla/service/hlo_graph_dumper.cc:454] computation cluster_28[_XlaCompiledKernel=true,_XlaNumConstantArgs=0,_XlaNumResourceArgs=0].v5 [CPU: after convolution-canonicalization, before simplification]: /tmp/hlo_graph_2.4hrkR3.dot
2017-06-10 16:22:45.609154: I tensorflow/compiler/xla/service/hlo_graph_dumper.cc:454] computation cluster_31[_XlaCompiledKernel=true,_XlaNumConstantArgs=0,_XlaNumResourceArgs=0].v5 [CPU: after convolution-canonicalization, before simplification]: /tmp/hlo_graph_3.HeUKAJ.dot
2017-06-10 16:22:45.609179: I tensorflow/compiler/xla/service/hlo_graph_dumper.cc:454] computation cluster_28[_XlaCompiledKernel=true,_XlaNumConstantArgs=0,_XlaNumResourceArgs=0].v5 [simplification: pipeline start, before algsimp]: /tmp/hlo_graph_4.VI87aX.dot

...

2017-06-10 16:23:40.250376: I tensorflow/compiler/xla/service/hlo_graph_dumper.cc:454] computation cluster_19[_XlaCompiledKernel=true,_XlaNumConstantArgs=0,_XlaNumResourceArgs=0].v9 [CPU: after dce, pipeline end]: /tmp/hlo_graph_33151.ks3lim.dot
2017-06-10 16:23:40.291384: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.291447: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n23 input 1: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.292857: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
     [[Node: n24 = StridedSlice[Index=DT_INT32, T=DT_INT32, _XlaCompile=true, _XlaScope="jit_scope_0", _XlaSeparateCompiledGradients=false, begin_mask=1, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=0](n22, n5, n15, n4)]]
    Conversion from TensorFlow graph to XLA computation failed.
2017-06-10 16:23:40.293537: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.293568: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.294546: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.295143: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.296903: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.298365: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.302371: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n23 input 1: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.302445: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n23 input 1: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.302472: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n23 input 1: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.302507: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n23 input 1: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.302531: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n23 input 1: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.302559: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n23 input 1: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.303833: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
     [[Node: n24 = StridedSlice[Index=DT_INT32, T=DT_INT32, _XlaCompile=true, _XlaScope="jit_scope_0", _XlaSeparateCompiledGradients=false, begin_mask=1, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=0](n22, n5, n15, n4)]]
    Conversion from TensorFlow graph to XLA computation failed.
2017-06-10 16:23:40.304199: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.304269: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
     [[Node: n24 = StridedSlice[Index=DT_INT32, T=DT_INT32, _XlaCompile=true, _XlaScope="jit_scope_0", _XlaSeparateCompiledGradients=false, begin_mask=1, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=0](n22, n5, n15, n4)]]
    Conversion from TensorFlow graph to XLA computation failed.
2017-06-10 16:23:40.304402: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
     [[Node: n24 = StridedSlice[Index=DT_INT32, T=DT_INT32, _XlaCompile=true, _XlaScope="jit_scope_0", _XlaSeparateCompiledGradients=false, begin_mask=1, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=0](n22, n5, n15, n4)]]
    Conversion from TensorFlow graph to XLA computation failed.
2017-06-10 16:23:40.304489: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n23 input 1: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.305516: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
     [[Node: n24 = StridedSlice[Index=DT_INT32, T=DT_INT32, _XlaCompile=true, _XlaScope="jit_scope_0", _XlaSeparateCompiledGradients=false, begin_mask=1, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=0](n22, n5, n15, n4)]]
    Conversion from TensorFlow graph to XLA computation failed.
2017-06-10 16:23:40.305792: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
     [[Node: n24 = StridedSlice[Index=DT_INT32, T=DT_INT32, _XlaCompile=true, _XlaScope="jit_scope_0", _XlaSeparateCompiledGradients=false, begin_mask=1, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=0](n22, n5, n15, n4)]]
    Conversion from TensorFlow graph to XLA computation failed.
2017-06-10 16:23:40.305846: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
     [[Node: n24 = StridedSlice[Index=DT_INT32, T=DT_INT32, _XlaCompile=true, _XlaScope="jit_scope_0", _XlaSeparateCompiledGradients=false, begin_mask=1, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=0](n22, n5, n15, n4)]]
    Conversion from TensorFlow graph to XLA computation failed.
2017-06-10 16:23:40.306228: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
     [[Node: n24 = StridedSlice[Index=DT_INT32, T=DT_INT32, _XlaCompile=true, _XlaScope="jit_scope_0", _XlaSeparateCompiledGradients=false, begin_mask=1, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=0](n22, n5, n15, n4)]]
    Conversion from TensorFlow graph to XLA computation failed.
2017-06-10 16:23:40.316243: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.316306: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n23 input 1: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.316378: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.316422: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n23 input 1: Operand to ComputeConstant depends on parameter.
2017-06-10 16:23:40.316850: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
     [[Node: n24 = StridedSlice[Index=DT_INT32, T=DT_INT32, _XlaCompile=true, _XlaScope="jit_scope_0", _XlaSeparateCompiledGradients=false, begin_mask=1, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=0](n22, n5, n15, n4)]]
    Conversion from TensorFlow graph to XLA computation failed.
2017-06-10 16:23:40.317028: W tensorflow/core/framework/op_kernel.cc:1152] Invalid argument: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
     [[Node: n24 = StridedSlice[Index=DT_INT32, T=DT_INT32, _XlaCompile=true, _XlaScope="jit_scope_0", _XlaSeparateCompiledGradients=false, begin_mask=1, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=0](n22, n5, n15, n4)]]
    Conversion from TensorFlow graph to XLA computation failed.
Traceback (most recent call last):
  File "Genetic Algorithm in Tensorflow-Part 2.py", line 280, in <module>
    sess.run(run_ga())
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 778, in run
    run_metadata_ptr)
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 982, in _run
    feed_dict_string, options, run_metadata)
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1032, in _do_run
    target_list, options, run_metadata)
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1052, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Error evaluating n24 input 2: Operand to ComputeConstant depends on parameter.
     [[Node: n24 = StridedSlice[Index=DT_INT32, T=DT_INT32, _XlaCompile=true, _XlaScope="jit_scope_0", _XlaSeparateCompiledGradients=false, begin_mask=1, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=0](n22, n5, n15, n4)]]
    Conversion from TensorFlow graph to XLA computation failed.
     [[Node: cluster_3/_2/_3 = _XlaLaunch[Nresources=0, Targs=[DT_INT32, DT_INT32], Tconstants=[DT_INT64, DT_INT32], Tresults=[DT_INT32], function=cluster_3[_XlaCompiledKernel=true, _XlaNumConstantArgs=2, _XlaNumResourceArgs=0], _device="/job:localhost/replica:0/task:0/cpu:0"](while/map/while/cond/multinomial/Multinomial, cluster_16/_20/_21:2, cluster_16/_20/_21, while/map/while/cond/strided_slice_2/Switch:1, ^cluster_16/_20/_21)]]

在文档中它说“如果无法编译运算符,TensorFlow 将默默地退回到正常的实现。” 那么为什么这次运行失败了呢?什么时候不能使用 XLA 编译?

作为参考,我在 OS X 上并从启用 XLA 的源代码编译了 Tensorflow r1.1。

我正在尝试编译的文件可在此处获得

4

0 回答 0