Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Member Functions
c10::cuda::OptionalCUDAStreamGuard Struct Reference

A variant of OptionalStreamGuard that is specialized for CUDA. More...

#include <CUDAGuard.h>

Public Member Functions

 OptionalCUDAStreamGuard ()
 Create an uninitialized guard.
 
 OptionalCUDAStreamGuard (Stream stream)
 Set the current CUDA device to the device associated with the passed stream, and set the current CUDA stream on that device to the passed stream. More...
 
 OptionalCUDAStreamGuard (optional< Stream > stream_opt)
 Set the current device to the device associated with the passed stream, and set the current stream on that device to the passed stream, if the passed stream is not nullopt. More...
 
 OptionalCUDAStreamGuard (const OptionalCUDAStreamGuard &)=delete
 Copy is disallowed.
 
OptionalCUDAStreamGuardoperator= (const OptionalCUDAStreamGuard &)=delete
 
 OptionalCUDAStreamGuard (OptionalCUDAStreamGuard &&other)=delete
 
OptionalCUDAStreamGuardoperator= (OptionalCUDAStreamGuard &&other)=delete
 
void reset_stream (Stream stream)
 Resets the currently set CUDA stream to the original stream and the currently set device to the original device. More...
 
optional< CUDAStreamoriginal_stream () const
 Returns the CUDA stream that was set at the time the guard was most recently initialized, or nullopt if the guard is uninitialized. More...
 
optional< CUDAStreamcurrent_stream () const
 Returns the most recent CUDA stream that was set using this stream guard, either from construction, or via reset_stream, if the guard is initialized, or nullopt if the guard is uninitialized. More...
 
void reset ()
 Restore the original CUDA device and stream, resetting this guard to uninitialized state.
 

Detailed Description

A variant of OptionalStreamGuard that is specialized for CUDA.

See CUDAGuard for when you can use this.

Definition at line 174 of file CUDAGuard.h.

Constructor & Destructor Documentation

c10::cuda::OptionalCUDAStreamGuard::OptionalCUDAStreamGuard ( Stream  stream)
inlineexplicit

Set the current CUDA device to the device associated with the passed stream, and set the current CUDA stream on that device to the passed stream.

Errors if the Stream is not a CUDA stream.

Definition at line 181 of file CUDAGuard.h.

c10::cuda::OptionalCUDAStreamGuard::OptionalCUDAStreamGuard ( optional< Stream stream_opt)
inlineexplicit

Set the current device to the device associated with the passed stream, and set the current stream on that device to the passed stream, if the passed stream is not nullopt.

Definition at line 186 of file CUDAGuard.h.

Member Function Documentation

optional<CUDAStream> c10::cuda::OptionalCUDAStreamGuard::current_stream ( ) const
inline

Returns the most recent CUDA stream that was set using this stream guard, either from construction, or via reset_stream, if the guard is initialized, or nullopt if the guard is uninitialized.

Definition at line 219 of file CUDAGuard.h.

optional<CUDAStream> c10::cuda::OptionalCUDAStreamGuard::original_stream ( ) const
inline

Returns the CUDA stream that was set at the time the guard was most recently initialized, or nullopt if the guard is uninitialized.

Definition at line 207 of file CUDAGuard.h.

void c10::cuda::OptionalCUDAStreamGuard::reset_stream ( Stream  stream)
inline

Resets the currently set CUDA stream to the original stream and the currently set device to the original device.

Then, set the current device to the device associated with the passed stream, and set the current stream on that device to the passed stream. Initializes the guard if it was not previously initialized.

Definition at line 203 of file CUDAGuard.h.


The documentation for this struct was generated from the following file: