nvidia.dali.fn.python_function — NVIDIA DALI (original) (raw)

nvidia.dali.fn.python_function(*input, batch_processing=False, bytes_per_sample_hint=[0], function, num_outputs=1, output_layouts=None, preserve=False, device=None, name=None)#

Executes a Python function.

This operator can be used to execute custom Python code in the DALI pipeline. The function receives the data from DALI as NumPy arrays in case of CPU operators or as CuPy arrays for GPU operators. It is expected to return the results in the same format. For a more universal data format, see nvidia.dali.fn.dl_tensor_python_function(). The function should not modify input tensors.

Warning

This operator is not compatible with TensorFlow integration.

Warning

When the pipeline has conditional execution enabled, additional steps must be taken to prevent the function from being rewritten by AutoGraph. There are two ways to achieve this:

  1. Define the function at global scope (i.e. outside of pipeline_def scope).
  2. If function is a result of another “factory” function, then the factory function must be defined outside pipeline definition function and decorated with@do_not_convert.

More details can be found in @do_not_convertdocumentation.

This operator allows sequence inputs and supports volumetric data.

This operator will not be optimized out of the graph.

Supported backends

Parameters:

__input_[ 0..255 ] (TensorList , optional) – This function accepts up to 256 optional positional inputs

Keyword Arguments:

See also