mxnet
Public Member Functions | Static Public Member Functions | List of all members
mxnet::cpp::Symbol Class Reference

Symbol interface. More...

#include <symbol.h>

Collaboration diagram for mxnet::cpp::Symbol:
Collaboration graph

Public Member Functions

 Symbol ()
 
 Symbol (SymbolHandle handle)
 construct a Symbol with SymbolHandle More...
 
 Symbol (const char *name)
 construct a variable Symbol More...
 
 Symbol (const std::string &name)
 construct a variable Symbol More...
 
Symbol operator+ (const Symbol &rhs) const
 
Symbol operator- (const Symbol &rhs) const
 
Symbol operator* (const Symbol &rhs) const
 
Symbol operator/ (const Symbol &rhs) const
 
Symbol operator% (const Symbol &rhs) const
 
Symbol operator+ (mx_float scalar) const
 
Symbol operator- (mx_float scalar) const
 
Symbol operator* (mx_float scalar) const
 
Symbol operator/ (mx_float scalar) const
 
Symbol operator% (mx_float scalar) const
 
Symbol Copy () const
 
Symbol operator[] (int index)
 
Symbol operator[] (const std::string &index)
 
void Save (const std::string &file_name) const
 save Symbol to a file More...
 
std::string ToJSON () const
 save Symbol into a JSON string More...
 
Symbol GetInternals () const
 save Symbol into a JSON string the symbol whose outputs are all the internals. More...
 
SymbolHandle GetHandle () const
 
 Symbol (const std::string &operator_name, const std::string &name, std::vector< const char * > input_keys, std::vector< SymbolHandle > input_values, std::vector< const char * > config_keys, std::vector< const char * > config_values)
 construct an operator Symbol, with given input Symbol and config More...
 
void InferShape (const std::map< std::string, std::vector< mx_uint > > &arg_shapes, std::vector< std::vector< mx_uint > > *in_shape, std::vector< std::vector< mx_uint > > *aux_shape, std::vector< std::vector< mx_uint > > *out_shape) const
 infer the shapes by providing shapes of known argument shapes. More...
 
std::vector< std::string > ListArguments () const
 List the arguments names. More...
 
std::vector< std::string > ListOutputs () const
 
std::vector< std::string > ListAuxiliaryStates () const
 
std::string GetName () const
 
void InferExecutorArrays (const Context &context, std::vector< NDArray > *arg_arrays, std::vector< NDArray > *grad_arrays, std::vector< OpReqType > *grad_reqs, std::vector< NDArray > *aux_arrays, const std::map< std::string, NDArray > &args_map, const std::map< std::string, NDArray > &arg_grad_store=std::map< std::string, NDArray >(), const std::map< std::string, OpReqType > &grad_req_type=std::map< std::string, OpReqType >(), const std::map< std::string, NDArray > &aux_map=std::map< std::string, NDArray >()) const
 infer and construct all the arrays to bind to executor by providing some known arrays. More...
 
void InferArgsMap (const Context &context, std::map< std::string, NDArray > *args_map, const std::map< std::string, NDArray > &known_args) const
 infer and construct all the input arguments arrays to bind to executor by providing some known arguments arrays. More...
 
ExecutorSimpleBind (const Context &context, const std::map< std::string, NDArray > &args_map, const std::map< std::string, NDArray > &arg_grad_store=std::map< std::string, NDArray >(), const std::map< std::string, OpReqType > &grad_req_type=std::map< std::string, OpReqType >(), const std::map< std::string, NDArray > &aux_map=std::map< std::string, NDArray >())
 Create an executor by bind symbol with context and arguments. If user do not want to compute the gradients of i-th argument, grad_req_type[i] can be kNullOp. The input arrays in the given maps should have the same name with the input symbol. Only need some of the necessary arrays, and the other arrays can be infered automatically. More...
 
ExecutorBind (const Context &context, const std::vector< NDArray > &arg_arrays, const std::vector< NDArray > &grad_arrays, const std::vector< OpReqType > &grad_reqs, const std::vector< NDArray > &aux_arrays, const std::map< std::string, Context > &group_to_ctx=std::map< std::string, Context >(), Executor *shared_exec=nullptr)
 Create an executor by bind symbol with context and arguments. If user do not want to compute the gradients of i-th argument, grad_req_type[i] can be kNullOp. More...
 

Static Public Member Functions

static Symbol Variable (const std::string &name="")
 construct a variable Symbol More...
 
static Symbol Group (const std::vector< Symbol > &symbols)
 Create a symbol that groups symbols together. More...
 
static Symbol Load (const std::string &file_name)
 load Symbol from a JSON file More...
 
static Symbol LoadJSON (const std::string &json_str)
 load Symbol from a JSON string More...
 

Detailed Description

Symbol interface.

Constructor & Destructor Documentation

mxnet::cpp::Symbol::Symbol ( )
inline
mxnet::cpp::Symbol::Symbol ( SymbolHandle  handle)
explicit

construct a Symbol with SymbolHandle

Parameters
handlethe given SymbolHandle
mxnet::cpp::Symbol::Symbol ( const char *  name)
explicit

construct a variable Symbol

Parameters
namethe name of the variable
mxnet::cpp::Symbol::Symbol ( const std::string &  name)
explicit

construct a variable Symbol

Parameters
namethe name of the variable
mxnet::cpp::Symbol::Symbol ( const std::string &  operator_name,
const std::string &  name,
std::vector< const char * >  input_keys,
std::vector< SymbolHandle input_values,
std::vector< const char * >  config_keys,
std::vector< const char * >  config_values 
)

construct an operator Symbol, with given input Symbol and config

Parameters
namethe name of the Symbol
input_keysthe vector of keys of the input
input_valuesthe vector of the intput Symbols
config_keysthe vector of keys of the config
config_valuesthe vecotr of values of the config

Member Function Documentation

Executor* mxnet::cpp::Symbol::Bind ( const Context context,
const std::vector< NDArray > &  arg_arrays,
const std::vector< NDArray > &  grad_arrays,
const std::vector< OpReqType > &  grad_reqs,
const std::vector< NDArray > &  aux_arrays,
const std::map< std::string, Context > &  group_to_ctx = std::map< std::string, Context >(),
Executor shared_exec = nullptr 
)

Create an executor by bind symbol with context and arguments. If user do not want to compute the gradients of i-th argument, grad_req_type[i] can be kNullOp.

Parameters
contextthe context of binding.
arg_arraysthe NDArray that stores the input arguments to the symbol.
grad_arraysNDArray that is used to store the gradient output of the input arguments.
grad_reqsrequirment type of gradient saving. Can only be in {kNullOp, kAddTo, kWriteTo}.
aux_arraysNDArray that is used as internal state in op
group_to_ctxdict of string to mx.Context
shared_execExecutor to share memory with. This is intended for runtime reshaping, variable length sequencesn etc. The returned executor shares state with shared_exec, and should not be used in parallel with it.
Returns
a new executor, which need to be free manually.
Symbol mxnet::cpp::Symbol::Copy ( ) const
SymbolHandle mxnet::cpp::Symbol::GetHandle ( ) const
inline
Returns
the SymbolHandle
Symbol mxnet::cpp::Symbol::GetInternals ( ) const

save Symbol into a JSON string the symbol whose outputs are all the internals.

std::string mxnet::cpp::Symbol::GetName ( ) const
Returns
get the name of the symbol
static Symbol mxnet::cpp::Symbol::Group ( const std::vector< Symbol > &  symbols)
static

Create a symbol that groups symbols together.

Parameters
symbolsList of symbols to be groupe
void mxnet::cpp::Symbol::InferArgsMap ( const Context context,
std::map< std::string, NDArray > *  args_map,
const std::map< std::string, NDArray > &  known_args 
) const

infer and construct all the input arguments arrays to bind to executor by providing some known arguments arrays.

Parameters
contextthe context of all the infered arrays.
args_mapmap of all the infered input arguments arrays.
known_argsmap of some given arguments arrays.
void mxnet::cpp::Symbol::InferExecutorArrays ( const Context context,
std::vector< NDArray > *  arg_arrays,
std::vector< NDArray > *  grad_arrays,
std::vector< OpReqType > *  grad_reqs,
std::vector< NDArray > *  aux_arrays,
const std::map< std::string, NDArray > &  args_map,
const std::map< std::string, NDArray > &  arg_grad_store = std::map< std::string, NDArray >(),
const std::map< std::string, OpReqType > &  grad_req_type = std::map< std::string, OpReqType >(),
const std::map< std::string, NDArray > &  aux_map = std::map< std::string, NDArray >() 
) const

infer and construct all the arrays to bind to executor by providing some known arrays.

Parameters
contextthe context of all the infered arrays
arg_arraysinfered input arguments arrays.
arad_arraysinfered arrays to store the gradient output of the input arguments.
aux_arraysinfered arrays that is used as internal state in op.
args_mapmap of some given arguments arrays.
args_grad_storemap of some gradient given store arrays.
args_req_typemap of some given type of gradient saving. Can only be in {kNullOp, kAddTo, kWriteTo}.
aux_mapNDArray that stores the internal state in op
void mxnet::cpp::Symbol::InferShape ( const std::map< std::string, std::vector< mx_uint > > &  arg_shapes,
std::vector< std::vector< mx_uint > > *  in_shape,
std::vector< std::vector< mx_uint > > *  aux_shape,
std::vector< std::vector< mx_uint > > *  out_shape 
) const

infer the shapes by providing shapes of known argument shapes.

Parameters
arg_shapesmap of argument name to shape of arguments with known shapes.
in_shapesused to store infered shapes of input arguments.
out_shapesused to store infered shapes of outputs.
aux_shapesuse to store the infered shapes of auxiliary states
std::vector<std::string> mxnet::cpp::Symbol::ListArguments ( ) const

List the arguments names.

The position of the returned list also corresponds to calling position in operator()

Returns
the arguments list of this symbol, they can be either named or unnamed (empty string).
std::vector<std::string> mxnet::cpp::Symbol::ListAuxiliaryStates ( ) const
Returns
get the descriptions of auxiliary data for this symbol
std::vector<std::string> mxnet::cpp::Symbol::ListOutputs ( ) const
Returns
get the descriptions of outputs for this symbol
static Symbol mxnet::cpp::Symbol::Load ( const std::string &  file_name)
static

load Symbol from a JSON file

Parameters
file_namethe name of the file
static Symbol mxnet::cpp::Symbol::LoadJSON ( const std::string &  json_str)
static

load Symbol from a JSON string

Parameters
json_strthe JSON string
Symbol mxnet::cpp::Symbol::operator% ( const Symbol rhs) const
Symbol mxnet::cpp::Symbol::operator% ( mx_float  scalar) const
Symbol mxnet::cpp::Symbol::operator* ( const Symbol rhs) const
Symbol mxnet::cpp::Symbol::operator* ( mx_float  scalar) const
Symbol mxnet::cpp::Symbol::operator+ ( const Symbol rhs) const
Symbol mxnet::cpp::Symbol::operator+ ( mx_float  scalar) const
Symbol mxnet::cpp::Symbol::operator- ( const Symbol rhs) const
Symbol mxnet::cpp::Symbol::operator- ( mx_float  scalar) const
Symbol mxnet::cpp::Symbol::operator/ ( const Symbol rhs) const
Symbol mxnet::cpp::Symbol::operator/ ( mx_float  scalar) const
Symbol mxnet::cpp::Symbol::operator[] ( int  index)
Symbol mxnet::cpp::Symbol::operator[] ( const std::string &  index)
void mxnet::cpp::Symbol::Save ( const std::string &  file_name) const

save Symbol to a file

Parameters
file_namethe name of the file
Executor* mxnet::cpp::Symbol::SimpleBind ( const Context context,
const std::map< std::string, NDArray > &  args_map,
const std::map< std::string, NDArray > &  arg_grad_store = std::map< std::string, NDArray >(),
const std::map< std::string, OpReqType > &  grad_req_type = std::map< std::string, OpReqType >(),
const std::map< std::string, NDArray > &  aux_map = std::map< std::string, NDArray >() 
)

Create an executor by bind symbol with context and arguments. If user do not want to compute the gradients of i-th argument, grad_req_type[i] can be kNullOp. The input arrays in the given maps should have the same name with the input symbol. Only need some of the necessary arrays, and the other arrays can be infered automatically.

Parameters
contextthe context of binding.
args_mapthe NDArray that stores the input arguments to the symbol.
arg_grad_storeNDArray that is used to store the gradient output of the input arguments.
grad_req_typerequirment type of gradient saving. Can only be in {kNullOp, kAddTo, kWriteTo}.
aux_mapNDArray that stores the internal state in op
Returns
a new executor, which need to be free manually.
std::string mxnet::cpp::Symbol::ToJSON ( ) const

save Symbol into a JSON string

static Symbol mxnet::cpp::Symbol::Variable ( const std::string &  name = "")
static

construct a variable Symbol

Parameters
namethe name of the variable

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