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

An OptionalStreamGuard is an RAII class that sets a device to some value on initialization, and resets the device to its original value on destruction. More...

#include <StreamGuard.h>

Public Member Functions

 OptionalStreamGuard ()
 Create an uninitialized guard.
 
 OptionalStreamGuard (Stream stream)
 Set the current device to the device associated with the passed stream, and set the current stream on that device to the passed stream. More...
 
 OptionalStreamGuard (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...
 
 OptionalStreamGuard (const OptionalStreamGuard &)=delete
 Copy is disallowed.
 
OptionalStreamGuardoperator= (const OptionalStreamGuard &)=delete
 
 OptionalStreamGuard (OptionalStreamGuard &&other)=delete
 
OptionalStreamGuardoperator= (OptionalStreamGuard &&other)=delete
 
void reset_stream (Stream stream)
 Resets the currently set stream to the original stream and the currently set device to the original device. More...
 
optional< Streamoriginal_stream () const
 Returns the stream that was set at the time the guard was most recently initialized, or nullopt if the guard is uninitialized. More...
 
optional< Streamcurrent_stream () const
 Returns the most recent 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 device and stream, resetting this guard to uninitialized state.
 

Detailed Description

An OptionalStreamGuard is an RAII class that sets a device to some value on initialization, and resets the device to its original value on destruction.

See OptionalDeviceGuard for more guidance on how to use this class.

Definition at line 80 of file StreamGuard.h.

Constructor & Destructor Documentation

c10::OptionalStreamGuard::OptionalStreamGuard ( Stream  stream)
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.

Definition at line 86 of file StreamGuard.h.

c10::OptionalStreamGuard::OptionalStreamGuard ( 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 91 of file StreamGuard.h.

Member Function Documentation

optional<Stream> c10::OptionalStreamGuard::current_stream ( ) const
inline

Returns the most recent 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 117 of file StreamGuard.h.

optional<Stream> c10::OptionalStreamGuard::original_stream ( ) const
inline

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

Definition at line 112 of file StreamGuard.h.

void c10::OptionalStreamGuard::reset_stream ( Stream  stream)
inline

Resets the currently set 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 108 of file StreamGuard.h.


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