Skip to main content

Python class

DeviceStream

DeviceStream

class max.driver.DeviceStream(self, device: max.driver.Device)

source

Bases: object

Provides access to a stream of execution on a device.

A stream represents a sequence of operations that will be executed in order. Multiple streams on the same device can execute concurrently.

from max import driver
device = driver.Accelerator()
# Get the default stream for the device
stream = device.default_stream
# Create a new stream of execution on the device
new_stream = driver.DeviceStream(device)

Creates a new stream of execution associated with the device.

Parameters:

device (Device) – The device to create the stream on.

Returns:

A new stream of execution.

Return type:

DeviceStream

device

property device

source

The device this stream is executing on.

record_event()

record_event(self) → max.driver.DeviceEvent

source

record_event(self, event: max.driver.DeviceEvent) → None

Overloaded function.

  1. record_event(self) -> max.driver.DeviceEvent

    Records an event on this stream. Returns: : DeviceEvent: A new event that will be signaled when all operations : submitted to this stream before this call have completed.

    Raises:
    ValueError: If recording the event failed.
  2. record_event(self, event: max.driver.DeviceEvent) -> None

    Records an existing event on this stream.

    Args:
    event (DeviceEvent): The event to record on this stream.
    Raises:
    ValueError: If recording the event failed.

synchronize()

synchronize(self) → None

source

Ensures all operations on this stream complete before returning.

Raises:

ValueError – If any enqueued operations had an internal error.

wait_for()

wait_for(self, stream: max.driver.DeviceStream) → None

source

wait_for(self, device: max.driver.Device) → None

Overloaded function.

  1. wait_for(self, stream: max.driver.DeviceStream) -> None

    Ensures all operations on the other stream complete before future work submitted to this stream is scheduled.

    Args:
    stream (DeviceStream): The stream to wait for.
  2. wait_for(self, device: max.driver.Device) -> None

    Ensures all operations on device’s default stream complete before future work submitted to this stream is scheduled.

    Args:
    device (Device): The device whose default stream to wait for.