Dragon - C++ API
A Computation Graph Virtual Machine Based Deep Learning Framework
Public Member Functions | Static Public Member Functions | List of all members
dragon::CPUContext Class Reference

#include <context.h>

Public Member Functions

 CPUContext ()
 Default Constructor. More...
 
 CPUContext (unsigned int random_seed)
 Constructor with the specified random seed. More...
 
 CPUContext (const DeviceOption &option)
 Constructor with the specified device option. More...
 
virtual ~CPUContext ()
 Deconstructor. More...
 
void SwitchToDevice ()
 Switch to the device of this context. More...
 
void SwitchToDevice (const int stream_id)
 Switch to the device with the given stream. More...
 
void FinishDeviceCompution ()
 Synchronize the dispatched operations. More...
 
void MemsetAsync (size_t nbytes, void *ptr)
 Zero-Reset the memory asynchronously. More...
 
template<class DstContext , class SrcContext >
void MemcpyAsync (size_t nbytes, void *dst, const void *src)
 Copy the memory asynchronously. More...
 
template<typename T , class DstContext , class SrcContext >
void Copy (int n, T *dst, const T *src)
 Copy the memory with given type asynchronously. More...
 
int device_id () const
 Return the device id. More...
 
int stream_id () const
 Return the stream id. More...
 
void set_stream_id (int stream_id)
 Set the stream id. More...
 
std::mt19937 * rand_generator ()
 Return the internal random generator. More...
 

Static Public Member Functions

static void * New (size_t nbytes)
 Malloc the memory. More...
 
static void Memset (size_t nbytes, void *ptr)
 Zero-Reset the memory. More...
 
template<class DstContext , class SrcContext >
static void Memcpy (size_t nbytes, void *dst, const void *src)
 Copy the memory. More...
 
static void Delete (void *data)
 Free the memory. More...
 

Constructor & Destructor Documentation

◆ CPUContext() [1/3]

dragon::CPUContext::CPUContext ( )
inline

Default Constructor.

◆ CPUContext() [2/3]

dragon::CPUContext::CPUContext ( unsigned int  random_seed)
inline

Constructor with the specified random seed.

◆ CPUContext() [3/3]

dragon::CPUContext::CPUContext ( const DeviceOption &  option)
inline

Constructor with the specified device option.

◆ ~CPUContext()

virtual dragon::CPUContext::~CPUContext ( )
inlinevirtual

Deconstructor.

Member Function Documentation

◆ Copy()

template<typename T , class DstContext , class SrcContext >
void dragon::CPUContext::Copy ( int  n,
T *  dst,
const T *  src 
)
inline

Copy the memory with given type asynchronously.

◆ Delete()

static void dragon::CPUContext::Delete ( void *  data)
inlinestatic

Free the memory.

◆ device_id()

int dragon::CPUContext::device_id ( ) const
inline

Return the device id.

◆ FinishDeviceCompution()

void dragon::CPUContext::FinishDeviceCompution ( )
inline

Synchronize the dispatched operations.

◆ Memcpy()

template<class DstContext , class SrcContext >
static void dragon::CPUContext::Memcpy ( size_t  nbytes,
void *  dst,
const void *  src 
)
inlinestatic

Copy the memory.

◆ MemcpyAsync()

template<class DstContext , class SrcContext >
void dragon::CPUContext::MemcpyAsync ( size_t  nbytes,
void *  dst,
const void *  src 
)
inline

Copy the memory asynchronously.

◆ Memset()

static void dragon::CPUContext::Memset ( size_t  nbytes,
void *  ptr 
)
inlinestatic

Zero-Reset the memory.

◆ MemsetAsync()

void dragon::CPUContext::MemsetAsync ( size_t  nbytes,
void *  ptr 
)
inline

Zero-Reset the memory asynchronously.

◆ New()

static void* dragon::CPUContext::New ( size_t  nbytes)
inlinestatic

Malloc the memory.

◆ rand_generator()

std::mt19937* dragon::CPUContext::rand_generator ( )
inline

Return the internal random generator.

◆ set_stream_id()

void dragon::CPUContext::set_stream_id ( int  stream_id)
inline

Set the stream id.

◆ stream_id()

int dragon::CPUContext::stream_id ( ) const
inline

Return the stream id.

◆ SwitchToDevice() [1/2]

void dragon::CPUContext::SwitchToDevice ( )
inline

Switch to the device of this context.

◆ SwitchToDevice() [2/2]

void dragon::CPUContext::SwitchToDevice ( const int  stream_id)
inline

Switch to the device with the given stream.


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