Enabled XLA for TF C API.
authorMingsheng Hong <hongm@google.com>
Fri, 9 Feb 2018 22:27:03 +0000 (14:27 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Fri, 9 Feb 2018 22:35:39 +0000 (14:35 -0800)
commit3590c452ea8485d063874138eec92411297a9abb
treefae3755a1858a7c31011e3b866108fb96c7ff779
parented5f003cc2c542c3c545369f71d4b57429da33fc
Enabled XLA for TF C API.

Summary of changes:

1. Set MarkForCompilationPassFlags::tf_xla_cpu_global_jit default to true in
C_API unit test env when XLA-execute is intended. Together with setting session
config config.graph_options.optimizer_options.global_jit_level to > 0, this
turns on XLA for the entire graph (eligible nodes only, with _Arg and _RetVal
nodes excluded).

We decided against defaulting MarkForCompilationPassFlags::tf_xla_cpu_global_jit
to true, due to performance concerns with the single-threaded nature of the XLA
CPU backend (see
https://www.tensorflow.org/performance/xla/jit#turning_on_jit_compilation).

2. In FindCompilationCandidates() during MarkForCompilationPass, skip compiling
any '_Arg'-typed nodes. This is necessary to avoid hitting a "Invalid argument
number" error during MarkForCompilationPass.

3. Extended C API based build rules to link in XLA libraries, and added unit
test "CAPI.Session_Min_XLA_CPU".

Also added some misc improvements and debugging aids.

PiperOrigin-RevId: 185193314
tensorflow/c/BUILD
tensorflow/c/c_api_test.cc
tensorflow/c/c_test_util.cc
tensorflow/c/c_test_util.h
tensorflow/compiler/jit/mark_for_compilation_pass.cc
tensorflow/compiler/tf2xla/const_analysis.cc
tensorflow/core/graph/graph.cc
tensorflow/core/graph/graph.h
tensorflow/core/graph/graph_constructor_test.cc
tensorflow/tools/lib_package/BUILD