Python class
DeviceStream
DeviceStream
class max.driver.DeviceStream(self, device: max.driver.Device)
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:
device
property device
The device this stream is executing on.
record_event()
record_event(self) → max.driver.DeviceEvent
record_event(self, event: max.driver.DeviceEvent) → None
Overloaded function.
-
record_event(self) -> max.driver.DeviceEventRecords 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.
-
record_event(self, event: max.driver.DeviceEvent) -> NoneRecords 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
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
wait_for(self, device: max.driver.Device) → None
Overloaded function.
-
wait_for(self, stream: max.driver.DeviceStream) -> NoneEnsures all operations on the other stream complete before future work submitted to this stream is scheduled.
- Args:
- stream (DeviceStream): The stream to wait for.
-
wait_for(self, device: max.driver.Device) -> NoneEnsures 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.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!