mxnet
|
#include <symbol.h>
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... | |
Executor * | 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. More... | |
Executor * | 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. 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... | |
Symbol interface.
|
inline |
|
explicit |
construct a Symbol with SymbolHandle
handle | the given SymbolHandle |
|
explicit |
construct a variable Symbol
name | the name of the variable |
|
explicit |
construct a variable Symbol
name | the 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 | ||
) |
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.
context | the context of binding. |
arg_arrays | the NDArray that stores the input arguments to the symbol. |
grad_arrays | NDArray that is used to store the gradient output of the input arguments. |
grad_reqs | requirment type of gradient saving. Can only be in {kNullOp, kAddTo, kWriteTo}. |
aux_arrays | NDArray that is used as internal state in op |
group_to_ctx | dict of string to mx.Context |
shared_exec | Executor 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. |
Symbol mxnet::cpp::Symbol::Copy | ( | ) | const |
|
inline |
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 |
Create a symbol that groups symbols together.
symbols | List 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.
context | the context of all the infered arrays. |
args_map | map of all the infered input arguments arrays. |
known_args | map 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.
context | the context of all the infered arrays |
arg_arrays | infered input arguments arrays. |
arad_arrays | infered arrays to store the gradient output of the input arguments. |
aux_arrays | infered arrays that is used as internal state in op. |
args_map | map of some given arguments arrays. |
args_grad_store | map of some gradient given store arrays. |
args_req_type | map of some given type of gradient saving. Can only be in {kNullOp, kAddTo, kWriteTo}. |
aux_map | NDArray 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.
arg_shapes | map of argument name to shape of arguments with known shapes. |
in_shapes | used to store infered shapes of input arguments. |
out_shapes | used to store infered shapes of outputs. |
aux_shapes | use 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()
std::vector<std::string> mxnet::cpp::Symbol::ListAuxiliaryStates | ( | ) | const |
std::vector<std::string> mxnet::cpp::Symbol::ListOutputs | ( | ) | const |
|
static |
load Symbol from a JSON file
file_name | the name of the file |
|
static |
load Symbol from a JSON string
json_str | the JSON string |
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
file_name | the 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.
context | the context of binding. |
args_map | the NDArray that stores the input arguments to the symbol. |
arg_grad_store | NDArray that is used to store the gradient output of the input arguments. |
grad_req_type | requirment type of gradient saving. Can only be in {kNullOp, kAddTo, kWriteTo}. |
aux_map | NDArray that stores the internal state in op |
std::string mxnet::cpp::Symbol::ToJSON | ( | ) | const |
save Symbol into a JSON string
|
static |
construct a variable Symbol
name | the name of the variable |