Go to the documentation of this file.
26 #ifndef MXNET_CPP_SYMBOL_H_
27 #define MXNET_CPP_SYMBOL_H_
85 explicit Symbol(
const char* name);
90 explicit Symbol(
const std::string& name);
114 static Symbol Group(
const std::vector<Symbol>& symbols);
119 static Symbol Load(
const std::string& file_name);
129 void Save(
const std::string& file_name)
const;
133 std::string
ToJSON()
const;
143 return (blob_ptr_) ? blob_ptr_->handle_ :
nullptr;
153 Symbol(
const std::string& operator_name,
154 const std::string& name,
155 std::vector<const char*> input_keys,
156 std::vector<SymbolHandle> input_values,
157 std::vector<const char*> config_keys,
158 std::vector<const char*> config_values);
167 void InferShape(
const std::map<std::string, std::vector<mx_uint> >& arg_shapes,
168 std::vector<std::vector<mx_uint> >* in_shape,
169 std::vector<std::vector<mx_uint> >* aux_shape,
170 std::vector<std::vector<mx_uint> >* out_shape)
const;
193 void SetAttribute(
const std::string& key,
const std::string& value);
198 void SetAttributes(
const std::map<std::string, std::string>& attrs);
221 std::vector<NDArray>* arg_arrays,
222 std::vector<NDArray>* grad_arrays,
223 std::vector<OpReqType>* grad_reqs,
224 std::vector<NDArray>* aux_arrays,
225 const std::map<std::string, NDArray>& args_map,
226 const std::map<std::string, NDArray>& arg_grad_store = std::map<std::string, NDArray>(),
227 const std::map<std::string, OpReqType>& grad_req_type = std::map<std::string, OpReqType>(),
228 const std::map<std::string, NDArray>& aux_map = std::map<std::string, NDArray>())
const;
237 std::map<std::string, NDArray>* args_map,
238 const std::map<std::string, NDArray>& known_args)
const;
259 const std::map<std::string, NDArray>& args_map,
260 const std::map<std::string, NDArray>& arg_grad_store = std::map<std::string, NDArray>(),
261 const std::map<std::string, OpReqType>& grad_req_type = std::map<std::string, OpReqType>(),
262 const std::map<std::string, NDArray>& aux_map = std::map<std::string, NDArray>());
283 const std::vector<NDArray>& arg_arrays,
284 const std::vector<NDArray>& grad_arrays,
285 const std::vector<OpReqType>& grad_reqs,
286 const std::vector<NDArray>& aux_arrays,
287 const std::map<std::string, Context>& group_to_ctx = std::map<std::string, Context>(),
291 std::shared_ptr<SymBlob> blob_ptr_;
292 static OpMap*& op_map();
301 #endif // MXNET_CPP_SYMBOL_H_
namespace of mxnet
Definition: api_registry.h:33
std::vector< std::string > ListOutputs() const
SymBlob(SymbolHandle handle)
construct with SymbolHandle to store
Definition: symbol.h:53
Symbol operator+(mx_float lhs, const Symbol &rhs)
ScalarExp< DType > scalar(DType s)
create an scalar expression
Definition: expression.h:103
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 argume...
MXNET_DLL int MXSymbolFree(SymbolHandle symbol)
Free the symbol handle.
std::string ToJSON() const
save Symbol into a JSON string
Symbol operator-(const Symbol &rhs) const
std::vector< std::string > ListArguments() const
List the arguments names.
void Save(const std::string &file_name) const
save Symbol to a file
Symbol operator-(mx_float lhs, const Symbol &rhs)
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.
std::vector< std::string > ListInputs() const
~SymBlob()
destructor, free the SymbolHandle
Definition: symbol.h:57
Symbol operator*(const Symbol &rhs) const
void SetAttribute(const std::string &key, const std::string &value)
set key-value attribute to the symbol
Context interface.
Definition: ndarray.h:45
std::vector< std::string > ListAuxiliaryStates() const
Symbol is help class used to represent the operator node in Graph.
Definition: symbolic.h:50
Symbol operator*(mx_float lhs, const Symbol &rhs)
OpMap instance holds a map of all the symbol creators so we can get symbol creators by name....
Definition: op_map.h:42
std::string GetName() const
float mx_float
manually define float
Definition: c_api.h:67
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 grad...
Symbol operator/(mx_float lhs, const Symbol &rhs)
Symbol operator+(const Symbol &rhs) const
SymBlob()
default constructor
Definition: symbol.h:49
static Symbol Load(const std::string &file_name)
load Symbol from a JSON file
Symbol operator/(const Symbol &rhs) const
mx_uint GetNumOutputs() const
Symbol GetInternals() const
save Symbol into a JSON string \retutrn the symbol whose outputs are all the internals.
mxnet::cpp::Symbol GetBackendSymbol(const std::string &backendName) const
void * SymbolHandle
handle to a symbol that can be bind as operator
Definition: c_api.h:82
Symbol()
Definition: symbol.h:75
SymbolHandle handle_
the SymbolHandle to store
Definition: symbol.h:63
std::map< std::string, std::string > ListAttributes() const
Executor interface.
Definition: executor.h:45
SymbolHandle GetHandle() const
Definition: symbol.h:142
Symbol operator[](int index)
struct to store SymbolHandle
Definition: symbol.h:44
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 grad...
void SetAttributes(const std::map< std::string, std::string > &attrs)
set a series of key-value attribute to the symbol
Symbol operator%(const Symbol &rhs) const
base definitions for mxnetcpp
Symbol operator%(mx_float lhs, const Symbol &rhs)
static Symbol Variable(const std::string &name="")
construct a variable Symbol
uint32_t mx_uint
manually define unsigned int
Definition: c_api.h:65
static Symbol Group(const std::vector< Symbol > &symbols)
Create a symbol that groups symbols together.
static Symbol LoadJSON(const std::string &json_str)
load Symbol from a JSON string
Symbol interface.
Definition: symbol.h:73
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.