![]() |
Builds an operator that compiles and runs computation
with XLA.
Aliases:
tf.xla.experimental.compile(
computation,
inputs=None
)
NOTE: In eager mode, computation
will have @tf.function
semantics.
Args:
computation
: A Python function that builds a computation to apply to the input. If the function takes n inputs, 'inputs' should be a list of n tensors.computation
may return a list of operations and tensors. Tensors must come before operations in the returned list. The return value ofcompile
is a list of tensors corresponding to the tensors from the output ofcomputation
.All
Operation
s returned fromcomputation
will be executed when evaluating any of the returned output tensors.inputs
: A list of inputs orNone
(equivalent to an empty list). Each input can be a nested structure containing values that are convertible to tensors. Note that passing an N-dimension list of compatible values will result in a N-dimension list of scalar tensors rather than a single Rank-N tensors. If you need different behavior, convert part of inputs to tensors withtf.convert_to_tensor
.
Returns:
Same data structure as if computation(*inputs) is called directly with some exceptions for correctness. Exceptions include: 1) None output: a NoOp would be returned which control-depends on computation. 2) Single value output: A tuple containing the value would be returned. 3) Operation-only outputs: a NoOp would be returned which control-depends on computation. TODO(b/121383831): Investigate into removing these special cases.
Raises:
RuntimeError
: if called when eager execution is enabled.