Pipeline API Overview#
In DALI Pipeline API, the processing is organized in a fixed graph of operations, defined ahead of time. A typical usage pattern involves defining a function decorated with @pipeline_def, constructing the Pipeline object, and executing it with batched data:
@pipeline_def
def my_pipe(flip_vertical, flip_horizontal):
"""Creates a DALI pipeline that returns flipped and original images."""
data, _ = fn.readers.file(file_root=images_dir)
img = fn.decoders.image(data, device="mixed")
flipped = fn.flip(img, horizontal=flip_horizontal, vertical=flip_vertical)
return flipped, img
pipe = my_pipe(True, False, batch_size=32, num_threads=1, device_id=0)
flipped, img = pipe.run()
The Pipeline class, with the associated data types and operations in nvidia.dali.fn and nvidia.dali.math modules are collectively called the DALI Pipeline API to distinguish it from the DALI Dynamic API.
DALI Dynamic API allows you to run its operators in an imperative manner without the necessity of defining the data processing graph upfront, at the cost of small performance overhead.
You can find more details in the Getting Started with Pipeline Mode tutorial.