Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Member Functions | Static Public Member Functions | Static Public Attributes
c10::impl::FakeGuardImpl< T > Struct Template Referencefinal

A fake implementation of DeviceGuardImplInterface suitable for testing. More...

#include <FakeGuardImpl.h>

Inheritance diagram for c10::impl::FakeGuardImpl< T >:
c10::impl::DeviceGuardImplInterface

Public Member Functions

 FakeGuardImpl (DeviceType)
 
DeviceType type () const override
 Return the type of device managed by this guard implementation.
 
Device exchangeDevice (Device d) const override
 Set the current device to Device, and return the previous Device.
 
Device getDevice () const override
 Get the current device.
 
void setDevice (Device d) const override
 Set the current device to Device.
 
void uncheckedSetDevice (Device d) const noexceptoverride
 Set the current device to Device, without checking for errors (so, e.g., this can be called from a destructor).
 
Stream getStream (Device d) const noexceptoverride
 Get the current stream for a given device.
 
Stream exchangeStream (Stream s) const noexceptoverride
 Set a stream to be the thread local current stream for its device. More...
 
DeviceIndex deviceCount () const override
 Get the number of devices.
 
- Public Member Functions inherited from c10::impl::DeviceGuardImplInterface
virtual ~DeviceGuardImplInterface ()=default
 Intended use of this class is to leak the DeviceGuardImpl at program end. More...
 

Static Public Member Functions

static DeviceIndex getDeviceIndex ()
 
static void setDeviceIndex (DeviceIndex i)
 
static StreamId getCurrentStreamIdFor (DeviceIndex i)
 
static void resetStreams ()
 

Static Public Attributes

static constexpr DeviceType static_type = T
 

Detailed Description

template<DeviceType T>
struct c10::impl::FakeGuardImpl< T >

A fake implementation of DeviceGuardImplInterface suitable for testing.

The current device is modeled as a mutable field in the guard implementation class. See DeviceGuard_test.cpp for an example use.

Definition at line 20 of file FakeGuardImpl.h.

Member Function Documentation

template<DeviceType T>
Stream c10::impl::FakeGuardImpl< T >::exchangeStream ( Stream  ) const
inlineoverridevirtualnoexcept

Set a stream to be the thread local current stream for its device.

Return the previous stream for that device. You are NOT required to set the current device to match the device of this stream.

Implements c10::impl::DeviceGuardImplInterface.

Definition at line 52 of file FakeGuardImpl.h.


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