Shortcuts

Class CUDAStream

Page Contents

Class Documentation

class CUDAStream

Public Types

enum Unchecked

Values:

enumerator UNCHECKED

Public Functions

inline explicit CUDAStream(Stream stream)

Construct a CUDAStream from a Stream.

This construction is checked, and will raise an error if the Stream is not, in fact, a CUDA stream.

inline explicit CUDAStream(Unchecked, Stream stream)

Construct a CUDAStream from a Stream with no error checking.

This constructor uses the “named” constructor idiom, and can be invoked as: CUDAStream(CUDAStream::UNCHECKED, stream)

inline bool operator==(const CUDAStream &other) const noexcept
inline bool operator!=(const CUDAStream &other) const noexcept
inline operator cudaStream_t() const

Implicit conversion to cudaStream_t.

inline operator Stream() const

Implicit conversion to Stream (a.k.a., forget that the stream is a CUDA stream).

inline DeviceType device_type() const

Used to avoid baking in device type explicitly to Python-side API.

inline DeviceIndex device_index() const

Get the CUDA device index that this stream is associated with.

inline Device device() const

Get the full Device that this stream is associated with.

The Device is guaranteed to be a CUDA device.

inline StreamId id() const

Return the stream ID corresponding to this particular stream.

inline bool query() const
inline void synchronize() const
inline int priority() const
cudaStream_t stream() const

Explicit conversion to cudaStream_t.

inline Stream unwrap() const

Explicit conversion to Stream.

inline struct c10::StreamData3 pack3() const

Reversibly pack a CUDAStream into a struct representation.

Previously the stream’s data was packed into a single int64_t, as it was assumed the fields would not require more than 64 bits of storage in total. See https://github.com/pytorch/pytorch/issues/75854 for more information regarding newer platforms that may violate this assumption.

The CUDAStream can be unpacked using unpack().

Public Static Functions

static inline CUDAStream unpack3(StreamId stream_id, DeviceIndex device_index, DeviceType device_type)
static inline std::tuple<int, int> priority_range()

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources