XLA, short for Accelerated Linear Algebra, is TensorFlow's high-performance compiler for optimizing function execution. It provides a faster compilation path than ordinary graph mode, with the trade-off of additional work during the first call. section 3.1 section 3.3.1
Compile a TensorFlow function with XLA
Add jit_compile=True to a TensorFlow function: @tf.function(jit_compile=True) def dense(inputs, W, b): return tf.nn.relu(tf.matmul(inputs, W) + b). TensorFlow compiles dense into an optimized program; the first call takes longer, while later calls can run faster. section 3.3.1
Use XLA with a simple workflow:
- Debug the function in the ordinary Python runtime first. section 3.3.1
- Apply @tf.function to enable TensorFlow graph mode. section 3.3.1
- Set jit_compile=True when the extra compilation work is worthwhile. section 3.3.1
@tf.function(jit_compile=True) def dense(inputs, W, b): return tf.nn.relu(tf.matmul(inputs, W) + b)
Inspect the compact TensorFlow example that enables XLA for a dense operation. section 3.3.1


