Just-in-time compilation converts program code during execution into an optimized form that can run faster afterward. In TensorFlow, wrap a function with tf_function() to compile its operations. section 3.3.1
Compiling a TensorFlow function
A dense layer can first be expressed as an ordinary R function, then wrapped with tf_function(). Setting jit_compile = TRUE requests just-in-time compilation for the wrapped computation. section 3.3.1
The technique appears alongside core numerical and automatic-differentiation operations:
- TensorFlow connects compilation with tensors, variables, numerical operations, and GradientTape. section 3.3.1
- JAX likewise treats just-in-time compilation as a way to make functions fast, alongside arrays, random operations, and gradients. section 3.5.1
library(tensorflow)
library(keras3)
use_backend("tensorflow")
Select the TensorFlow backend before experimenting with the compilation examples. section 3.3.1






