Batches all the inputs tensors to the computation done by the function.

So, for example, in the following code

  # This input will be captured.
  y = tf.placeholder_with_default(1.0, shape=[])

  def computation(a):
    return tf.matmul(a, a) + y

  b = gen_batch_ops.batch_function(
          Tout=[o.type for o in computation.definition.signature.output_arg],
          batch_timeout_micros=100000,  # 100ms
          allowed_batch_sizes=[3, 10],

If more than one call is simultaneously trying to compute b the values of a will be gathered, non-deterministically concatenated along the first axis, and only one thread will run the computation.

Assumes that all arguments of the function are Tensors which will be batched along their first dimension.

Arguments that are captured, are not batched. The call which does the concatenation, will use the values of the captured tensors available to it. Therefore, typical uses of captured tensors should involve values which remain unchanged across calls. Inference is a good example of this.

SparseTensor is not supported. The return value of the decorated function must be a Tensor or a list/tuple of Tensors.

in_tensors A list of Tensor objects. The tensors to be batched.
captured_tensors A list of Tensor objects. The tensors which are captured in the function, and don't need to be batched.
f A function decorated with @Defun.
num_batch_threads An int. Number of scheduling threads for processing batches of work. Determines the number of batches processed in parallel.
max_batch_size An int. Batch sizes will never be bigger than this.
batch_timeout_micros An int. Maximum number of microseconds to wait before outputting an incomplete batch.
Tout A list of tf.DTypes that has length >= 1. the types of the output tensors.
max_enqueued_batches An optional int. Defaults to 10. Maximum number of batches enqueued. Default: 10.
allowed_batch_sizes An optional list of ints