mxnet
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
mxnet::Context Struct Reference

Context information about the execution environment. More...

#include <base.h>

Collaboration diagram for mxnet::Context:
Collaboration graph

Public Types

enum  DeviceType { kCPU = cpu::kDevMask, kGPU = gpu::kDevMask, kCPUPinned = 3, kCPUShared = 5 }
 Type of device. More...
 

Public Member Functions

 Context ()
 default constructor More...
 
DeviceType dev_mask () const
 Get corresponding device mask. More...
 
int real_dev_id () const
 Returns dev_id for kGPU, 0 otherwise. More...
 
bool operator< (const Context &b) const
 Comparator, used to enable Context as std::map key. More...
 
bool operator== (const Context &b) const
 check if current context equals another one More...
 
bool operator!= (const Context &b) const
 check if current context not equals another one More...
 
void Save (dmlc::Stream *strm) const
 save the content into binary stream More...
 
bool Load (dmlc::Stream *strm)
 load the content from binary stream More...
 

Static Public Member Functions

static Context Create (DeviceType dev_type, int32_t dev_id=-1)
 Create a new context. More...
 
static Context CPU (int32_t dev_id=0)
 
static Context GPU (int32_t dev_id=-1)
 
static Context CPUPinned (int32_t dev_id=-1)
 
static Context CPUShared (int32_t dev_id=0)
 
static Context FromString (std::string str)
 

Public Attributes

DeviceType dev_type
 the device type we run the op on More...
 
int32_t dev_id
 device id we are going to run it on More...
 

Static Public Attributes

static const int32_t kMaxDevType = 6
 the maximal device type More...
 
static const int32_t kMaxDevID = 16
 the maximal device index More...
 

Detailed Description

Context information about the execution environment.

Member Enumeration Documentation

Type of device.

Enumerator
kCPU 
kGPU 
kCPUPinned 
kCPUShared 

Constructor & Destructor Documentation

mxnet::Context::Context ( )
inline

default constructor

Member Function Documentation

static Context mxnet::Context::CPU ( int32_t  dev_id = 0)
inlinestatic
Returns
CPU Context
static Context mxnet::Context::CPUPinned ( int32_t  dev_id = -1)
inlinestatic

Create a pinned CPU context.

Parameters
dev_idthe device id for corresponding GPU.
Returns
Pinned CPU context. -1 for current GPU.
static Context mxnet::Context::CPUShared ( int32_t  dev_id = 0)
inlinestatic

Create a CPU shared memory context.

Parameters
dev_iddummy device id.
Returns
CPU shared memory context.
static Context mxnet::Context::Create ( DeviceType  dev_type,
int32_t  dev_id = -1 
)
inlinestatic

Create a new context.

Parameters
dev_typedevice type.
dev_iddevice id. -1 for current device.
DeviceType mxnet::Context::dev_mask ( ) const
inline

Get corresponding device mask.

Returns
cpu::kDevMask or gpu::kDevMask
static Context mxnet::Context::FromString ( std::string  str)
inlinestatic

Create a context from string of the format [cpu|gpu|cpu_pinned](n)

Parameters
strthe string pattern
Returns
Context
static Context mxnet::Context::GPU ( int32_t  dev_id = -1)
inlinestatic

Create a GPU context.

Parameters
dev_idthe device id.
Returns
GPU Context. -1 for current GPU.
bool mxnet::Context::Load ( dmlc::Stream *  strm)
inline

load the content from binary stream

Parameters
strmthe output stream
Returns
whether the load is successful
bool mxnet::Context::operator!= ( const Context b) const
inline

check if current context not equals another one

Parameters
banother context to compare
Returns
whether they are not the same
bool mxnet::Context::operator< ( const Context b) const
inline

Comparator, used to enable Context as std::map key.

Parameters
banother context to compare
Returns
compared result
bool mxnet::Context::operator== ( const Context b) const
inline

check if current context equals another one

Parameters
banother context to compare
Returns
whether dev mask and id are same
int mxnet::Context::real_dev_id ( ) const
inline

Returns dev_id for kGPU, 0 otherwise.

void mxnet::Context::Save ( dmlc::Stream *  strm) const
inline

save the content into binary stream

Parameters
strmthe output stream

Member Data Documentation

int32_t mxnet::Context::dev_id

device id we are going to run it on

DeviceType mxnet::Context::dev_type

the device type we run the op on

const int32_t mxnet::Context::kMaxDevID = 16
static

the maximal device index

const int32_t mxnet::Context::kMaxDevType = 6
static

the maximal device type


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