Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Member Functions
c10::impl::InlineOptionalStreamGuard< T > Class Template 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 <InlineStreamGuard.h>

Public Member Functions

 InlineOptionalStreamGuard ()
 Creates an uninitialized stream guard.
 
 InlineOptionalStreamGuard (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...
 
template<typename... Args>
 InlineOptionalStreamGuard (Args &&...args)
 All constructors of StreamGuard are valid for OptionalStreamGuard.
 
 InlineOptionalStreamGuard (InlineOptionalStreamGuard< T > &&other)=delete
 
InlineOptionalStreamGuardoperator= (InlineOptionalStreamGuard &&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

template<typename T>
class c10::impl::InlineOptionalStreamGuard< T >

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 InlineOptionalDeviceGuard for more guidance on how to use this class.

Definition at line 124 of file InlineStreamGuard.h.

Constructor & Destructor Documentation

template<typename T>
c10::impl::InlineOptionalStreamGuard< T >::InlineOptionalStreamGuard ( 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 134 of file InlineStreamGuard.h.

Member Function Documentation

template<typename T>
optional<Stream> c10::impl::InlineOptionalStreamGuard< T >::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 174 of file InlineStreamGuard.h.

template<typename T>
optional<Stream> c10::impl::InlineOptionalStreamGuard< T >::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 167 of file InlineStreamGuard.h.

template<typename T>
void c10::impl::InlineOptionalStreamGuard< T >::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 OptionalStreamGuard if it was not previously initialized.

Definition at line 157 of file InlineStreamGuard.h.


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