mxnet
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
mxnet::Imperative Class Reference

runtime functions for NDArray More...

#include <imperative.h>

Collaboration diagram for mxnet::Imperative:
Collaboration graph

Classes

class  AGInfo
 
class  DCInfo
 DCInfo datastructure to enable deferred computation. More...
 

Public Member Functions

bool is_training () const
 whether operator recording is on. More...
 
bool set_is_training (bool is_train)
 turn on or turn off operator recording for autograd. More...
 
bool is_recording () const
 whether operator recording is on. More...
 
bool set_is_recording (bool is_recording)
 turn on or turn off operator recording for autograd. More...
 
bool is_deferred_compute () const
 whether deferred compute mode is on. More...
 
bool set_is_deferred_compute (bool is_deferred_compute)
 turn on or turn off operator recording for autograd. More...
 
int is_np_shape () const
 return current numpy compatibility status, GlobalOn(2), ThreadLocalOn(1), Off(0). More...
 
bool set_is_np_shape (int is_np_shape)
 specify numpy compatibility off, thread local on or global on. More...
 
bool is_np_default_dtype () const
 return current numpy default dtype compatibility status. More...
 
bool set_is_np_default_dtype (bool is_np_default_dtype)
 specify numpy default dtype off or global on. More...
 
OptConstraint get_opt_constraints () const
 return current optimization constraints. More...
 
OptConstraint set_opt_constraints (OptConstraint constraints)
 set optimization constraints. More...
 
void RecordOp (nnvm::NodeAttrs &&attrs, const std::vector< NDArray * > &inputs, const std::vector< NDArray * > &outputs, const OpStatePtr &state=OpStatePtr(), std::vector< bool > *p_save_inputs=nullptr, std::vector< bool > *p_save_outputs=nullptr)
 to record operator, return corresponding node. More...
 
void RecordDeferredCompute (nnvm::NodeAttrs &&attrs, const std::vector< NDArray * > &inputs, const std::vector< NDArray * > &outputs)
 to record operator, return corresponding node. More...
 
nnvm::Symbol GetDeferredComputeSymbol (const std::vector< NDArray * > &outputs)
 obtain symbol representation of deferred compute session. More...
 
void SetDeferredComputeVariable (NDArrayHandle *arrays, SymbolHandle *variables, const int num)
 associate arrays with variables for deferred compute More...
 
void DeferredComputeClear (NDArrayHandle *arrays, const int num)
 clear info node associated with array More...
 
OpStatePtr Invoke (const Context &default_ctx, const nnvm::NodeAttrs &attrs, const std::vector< NDArray * > &inputs, const std::vector< NDArray * > &outputs)
 
OpStatePtr InvokeOp (const Context &ctx, const nnvm::NodeAttrs &attrs, const std::vector< NDArray * > &inputs, const std::vector< NDArray * > &outputs, const std::vector< OpReqType > &req, const DispatchMode dispatch_mode, OpStatePtr state=OpStatePtr())
 
void MarkVariables (const std::vector< NDArray * > &variables, const std::vector< uint32_t > &grad_reqs, const std::vector< NDArray * > &gradients)
 mark variables for computing gradients. More...
 
void DropGrads (const std::vector< NDArray * > &variables)
 unmark nonleaf variables to free the memory. More...
 
std::vector< NDArray * > Backward (const std::vector< NDArray * > &outputs, const std::vector< NDArray * > &ograds, const std::vector< NDArray * > &variables, bool is_train, bool retain_graph, bool create_graph)
 compute the gradient of outputs w.r.t variables. More...
 
std::vector< nnvm::ObjectPtrListNonleafVariables (const nnvm::Symbol &sym) const
 Return the marked nonleaf nodes. More...
 

Static Public Member Functions

static ImperativeGet ()
 
static bool PreferBulkExecInference ()
 Should op execution bulking be employed during inference. More...
 
static bool PreferBulkExecTrain ()
 Should op execution bulking be employed during training. More...
 
static int BulkExecMaxNodeTrainFwd ()
 The max number of op nodes in a bulk during forward pass of training. More...
 
static int BulkExecMaxNodeTrainBwd ()
 The max number of op nodes in a bulk during backward pass of training. More...
 

Friends

class NDArray
 

Detailed Description

runtime functions for NDArray

Member Function Documentation

◆ Backward()

std::vector<NDArray*> mxnet::Imperative::Backward ( const std::vector< NDArray * > &  outputs,
const std::vector< NDArray * > &  ograds,
const std::vector< NDArray * > &  variables,
bool  is_train,
bool  retain_graph,
bool  create_graph 
)

compute the gradient of outputs w.r.t variables.

◆ BulkExecMaxNodeTrainBwd()

static int mxnet::Imperative::BulkExecMaxNodeTrainBwd ( )
inlinestatic

The max number of op nodes in a bulk during backward pass of training.

◆ BulkExecMaxNodeTrainFwd()

static int mxnet::Imperative::BulkExecMaxNodeTrainFwd ( )
inlinestatic

The max number of op nodes in a bulk during forward pass of training.

◆ DeferredComputeClear()

void mxnet::Imperative::DeferredComputeClear ( NDArrayHandle arrays,
const int  num 
)

clear info node associated with array

◆ DropGrads()

void mxnet::Imperative::DropGrads ( const std::vector< NDArray * > &  variables)

unmark nonleaf variables to free the memory.

◆ Get()

static Imperative* mxnet::Imperative::Get ( )
static
Returns
AutogradRuntime singleton

◆ get_opt_constraints()

OptConstraint mxnet::Imperative::get_opt_constraints ( ) const
inline

return current optimization constraints.

◆ GetDeferredComputeSymbol()

nnvm::Symbol mxnet::Imperative::GetDeferredComputeSymbol ( const std::vector< NDArray * > &  outputs)

obtain symbol representation of deferred compute session.

◆ Invoke()

OpStatePtr mxnet::Imperative::Invoke ( const Context default_ctx,
const nnvm::NodeAttrs attrs,
const std::vector< NDArray * > &  inputs,
const std::vector< NDArray * > &  outputs 
)

◆ InvokeOp()

OpStatePtr mxnet::Imperative::InvokeOp ( const Context ctx,
const nnvm::NodeAttrs attrs,
const std::vector< NDArray * > &  inputs,
const std::vector< NDArray * > &  outputs,
const std::vector< OpReqType > &  req,
const DispatchMode  dispatch_mode,
OpStatePtr  state = OpStatePtr() 
)

◆ is_deferred_compute()

bool mxnet::Imperative::is_deferred_compute ( ) const
inline

whether deferred compute mode is on.

◆ is_np_default_dtype()

bool mxnet::Imperative::is_np_default_dtype ( ) const
inline

return current numpy default dtype compatibility status.

◆ is_np_shape()

int mxnet::Imperative::is_np_shape ( ) const
inline

return current numpy compatibility status, GlobalOn(2), ThreadLocalOn(1), Off(0).

◆ is_recording()

bool mxnet::Imperative::is_recording ( ) const
inline

whether operator recording is on.

◆ is_training()

bool mxnet::Imperative::is_training ( ) const
inline

whether operator recording is on.

◆ ListNonleafVariables()

std::vector<nnvm::ObjectPtr> mxnet::Imperative::ListNonleafVariables ( const nnvm::Symbol sym) const

Return the marked nonleaf nodes.

◆ MarkVariables()

void mxnet::Imperative::MarkVariables ( const std::vector< NDArray * > &  variables,
const std::vector< uint32_t > &  grad_reqs,
const std::vector< NDArray * > &  gradients 
)

mark variables for computing gradients.

◆ PreferBulkExecInference()

static bool mxnet::Imperative::PreferBulkExecInference ( )
inlinestatic

Should op execution bulking be employed during inference.

◆ PreferBulkExecTrain()

static bool mxnet::Imperative::PreferBulkExecTrain ( )
inlinestatic

Should op execution bulking be employed during training.

◆ RecordDeferredCompute()

void mxnet::Imperative::RecordDeferredCompute ( nnvm::NodeAttrs &&  attrs,
const std::vector< NDArray * > &  inputs,
const std::vector< NDArray * > &  outputs 
)

to record operator, return corresponding node.

◆ RecordOp()

void mxnet::Imperative::RecordOp ( nnvm::NodeAttrs &&  attrs,
const std::vector< NDArray * > &  inputs,
const std::vector< NDArray * > &  outputs,
const OpStatePtr state = OpStatePtr(),
std::vector< bool > *  p_save_inputs = nullptr,
std::vector< bool > *  p_save_outputs = nullptr 
)

to record operator, return corresponding node.

◆ set_is_deferred_compute()

bool mxnet::Imperative::set_is_deferred_compute ( bool  is_deferred_compute)
inline

turn on or turn off operator recording for autograd.

◆ set_is_np_default_dtype()

bool mxnet::Imperative::set_is_np_default_dtype ( bool  is_np_default_dtype)
inline

specify numpy default dtype off or global on.

◆ set_is_np_shape()

bool mxnet::Imperative::set_is_np_shape ( int  is_np_shape)
inline

specify numpy compatibility off, thread local on or global on.

◆ set_is_recording()

bool mxnet::Imperative::set_is_recording ( bool  is_recording)
inline

turn on or turn off operator recording for autograd.

◆ set_is_training()

bool mxnet::Imperative::set_is_training ( bool  is_train)
inline

turn on or turn off operator recording for autograd.

◆ set_opt_constraints()

OptConstraint mxnet::Imperative::set_opt_constraints ( OptConstraint  constraints)
inline

set optimization constraints.

◆ SetDeferredComputeVariable()

void mxnet::Imperative::SetDeferredComputeVariable ( NDArrayHandle arrays,
SymbolHandle variables,
const int  num 
)

associate arrays with variables for deferred compute

Friends And Related Function Documentation

◆ NDArray

friend class NDArray
friend

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