mxnet
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Member Functions | List of all members
mxnet::Engine Class Referenceabstract

Dependency engine that schedules operations. More...

#include <engine.h>

Collaboration diagram for mxnet::Engine:
Collaboration graph

Public Types

typedef engine::CallbackOnComplete CallbackOnComplete
 callback on complete More...
 
typedef std::function< void(RunContext)> SyncFn
 Synchronous operation to pass to engine. More...
 
typedef std::function< void(RunContext,
CallbackOnComplete)> 
AsyncFn
 Asynchronous operation to pass to engine. More...
 
typedef engine::VarHandle VarHandle
 Variable pointer. More...
 
typedef engine::OprHandle OprHandle
 Operator pointer. More...
 

Public Member Functions

virtual void NotifyShutdown ()=0
 Notify the engine about a shutdown, This can help engine to print less messages into display. More...
 
virtual void Stop ()
 Stop all workers in the engine. More...
 
virtual void Start ()
 Restart all workers in the engine. More...
 
virtual VarHandle NewVariable ()=0
 Allocate a new variable, the variable can then be used to schedule the operation concurrently via dependency patterns. More...
 
virtual OprHandle NewOperator (AsyncFn fn, std::vector< VarHandle > const &const_vars, std::vector< VarHandle > const &mutable_vars, FnProperty prop=FnProperty::kNormal, const char *opr_name=nullptr)=0
 Create a new operator. The returned operator could be saved externally so that it could be resued for scheduling. More...
 
virtual void DeleteOperator (OprHandle op)=0
 Delete the given operator. More...
 
virtual void Push (OprHandle op, Context exec_ctx, int priority=0, bool profiling=false)=0
 Push an operator to the engine. More...
 
virtual void PushAsync (AsyncFn exec_fun, Context exec_ctx, std::vector< VarHandle > const &const_vars, std::vector< VarHandle > const &mutable_vars, FnProperty prop=FnProperty::kNormal, int priority=0, const char *opr_name=nullptr)=0
 Push an asynchronous operation to the engine. More...
 
virtual void DeleteVariable (SyncFn delete_fn, Context exec_ctx, VarHandle var)=0
 Schedule the deletion of a variable. More...
 
virtual void WaitForVar (VarHandle var)=0
 Wait for a variable. More...
 
virtual void WaitForAll ()=0
 Wait until all the activity of engine finishes. More...
 
virtual ~Engine () noexcept(false)
 virtual destructor More...
 
virtual void PushSync (SyncFn exec_fn, Context exec_ctx, std::vector< VarHandle > const &const_vars, std::vector< VarHandle > const &mutable_vars, FnProperty prop=FnProperty::kNormal, int priority=0, const char *opr_name=nullptr)
 Push an synchronous operation to the engine. More...
 
CallbackOnComplete CreateCallback (void(*callback)(Engine *, void *), void *param)
 factory function to create OnComplete callback. More...
 
void DeduplicateVarHandle (std::vector< engine::VarHandle > *read_vars, std::vector< engine::VarHandle > *write_vars)
 
virtual int bulk_size () const
 query current limit for bulk size More...
 
virtual int set_bulk_size (int)
 set maximum limit for bulk size More...
 

Static Public Member Functions

static EngineGet ()
 
static std::shared_ptr< Engine_GetSharedRef ()
 Get shared pointer reference to engine singleton. Most user should not call this function. This function is called by another singleton X who requires engine to be destructed after X. More...
 

Detailed Description

Dependency engine that schedules operations.

Member Typedef Documentation

typedef std::function<void(RunContext, CallbackOnComplete)> mxnet::Engine::AsyncFn

Asynchronous operation to pass to engine.

callback on complete

Operator pointer.

typedef std::function<void(RunContext)> mxnet::Engine::SyncFn

Synchronous operation to pass to engine.

Variable pointer.

Constructor & Destructor Documentation

virtual mxnet::Engine::~Engine ( )
inlinevirtualnoexcept

virtual destructor

Member Function Documentation

static std::shared_ptr<Engine> mxnet::Engine::_GetSharedRef ( )
static

Get shared pointer reference to engine singleton. Most user should not call this function. This function is called by another singleton X who requires engine to be destructed after X.

Returns
A shared pointer to Engine singleton.
virtual int mxnet::Engine::bulk_size ( ) const
inlinevirtual

query current limit for bulk size

CallbackOnComplete mxnet::Engine::CreateCallback ( void(*)(Engine *, void *)  callback,
void *  param 
)
inline

factory function to create OnComplete callback.

Parameters
callbackth static callback function.
paramthe paramter passed to callback.
void mxnet::Engine::DeduplicateVarHandle ( std::vector< engine::VarHandle > *  read_vars,
std::vector< engine::VarHandle > *  write_vars 
)
inline
virtual void mxnet::Engine::DeleteOperator ( OprHandle  op)
pure virtual

Delete the given operator.

Parameters
opThe operator to delete.

The delete will not happen immediately, but will wait until all the operations using this operator are completed.

virtual void mxnet::Engine::DeleteVariable ( SyncFn  delete_fn,
Context  exec_ctx,
VarHandle  var 
)
pure virtual

Schedule the deletion of a variable.

The delete will not happen immediately, but will wait until all the operations depending on var are completed.

Parameters
delete_fnA function that will be called after the variable is deleted.
exec_ctxExecution context.
varThe variable to be deleted.
static Engine* mxnet::Engine::Get ( )
static
Returns
Engine singleton.
virtual OprHandle mxnet::Engine::NewOperator ( AsyncFn  fn,
std::vector< VarHandle > const &  const_vars,
std::vector< VarHandle > const &  mutable_vars,
FnProperty  prop = FnProperty::kNormal,
const char *  opr_name = nullptr 
)
pure virtual

Create a new operator. The returned operator could be saved externally so that it could be resued for scheduling.

Parameters
fnThe execution function.
const_varsThe variables that current operation will use but not mutate.
mutable_varsThe variables that current operation will mutate.
propProperty of the function.
opr_nameThe operator name.
Returns
The new operator allocated.
virtual VarHandle mxnet::Engine::NewVariable ( )
pure virtual

Allocate a new variable, the variable can then be used to schedule the operation concurrently via dependency patterns.

Returns
The new variable allocated.
virtual void mxnet::Engine::NotifyShutdown ( )
pure virtual

Notify the engine about a shutdown, This can help engine to print less messages into display.

User do not have to call this function.

Returns
0 when success, -1 when failure happens.
virtual void mxnet::Engine::Push ( OprHandle  op,
Context  exec_ctx,
int  priority = 0,
bool  profiling = false 
)
pure virtual

Push an operator to the engine.

Parameters
opThe operator to push.
exec_ctxExecution context.
priorityPriority of the action, as hint to the engine.
profilingThe variable indicate whether to profile this operator.
virtual void mxnet::Engine::PushAsync ( AsyncFn  exec_fun,
Context  exec_ctx,
std::vector< VarHandle > const &  const_vars,
std::vector< VarHandle > const &  mutable_vars,
FnProperty  prop = FnProperty::kNormal,
int  priority = 0,
const char *  opr_name = nullptr 
)
pure virtual

Push an asynchronous operation to the engine.

Parameters
exec_funExecution function, this function takes a parameter on_complete that must be called when the execution completes.
exec_ctxExecution context.
const_varsThe variables that current operation will use but not mutate.
mutable_varsThe variables that current operation will mutate.
propProperty of the function.
priorityPriority of the action, as hint to the engine.
opr_nameThe operator name.
virtual void mxnet::Engine::PushSync ( SyncFn  exec_fn,
Context  exec_ctx,
std::vector< VarHandle > const &  const_vars,
std::vector< VarHandle > const &  mutable_vars,
FnProperty  prop = FnProperty::kNormal,
int  priority = 0,
const char *  opr_name = nullptr 
)
inlinevirtual

Push an synchronous operation to the engine.

Parameters
exec_fnExecution function that executes the operation.
exec_ctxExecution context.
const_varsThe variables that current operation will use but not mutate.
mutable_varsThe variables that current operation will mutate.
propProperty of the function.
priorityPriority of the action, as hint to the engine.
opr_nameThe operator name.
Template Parameters
SyncFnthe synchronous function to be pushed.
virtual int mxnet::Engine::set_bulk_size ( int  )
inlinevirtual

set maximum limit for bulk size

virtual void mxnet::Engine::Start ( )
inlinevirtual

Restart all workers in the engine.

virtual void mxnet::Engine::Stop ( )
inlinevirtual

Stop all workers in the engine.

virtual void mxnet::Engine::WaitForAll ( )
pure virtual

Wait until all the activity of engine finishes.

virtual void mxnet::Engine::WaitForVar ( VarHandle  var)
pure virtual

Wait for a variable.

Parameters
varThe variable we should wait for. This function returns when the variable is ready.

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