mxnet
|
Symbol is help class used to represent the operator node in Graph. More...
#include <symbolic.h>
Public Types | |
enum | ListAttrOption { kRecursive = 0, kShallow = 1 } |
option passed to ListAttr More... | |
enum | ListInputOption { kAll = 0, kReadOnlyArgs = 1, kAuxiliaryStates = 2 } |
option passed to ListInputNames More... | |
Public Member Functions | |
Symbol | Copy () const |
Copy the symbol. More... | |
void | Print (std::ostream &os) const |
Print the symbol info to output stream. More... | |
Symbol | operator[] (size_t index) const |
Get the index-th element from the returned tuple. More... | |
std::vector< ObjectPtr > | ListInputs (ListInputOption option) const |
List the input variable nodes. More... | |
std::vector< std::string > | ListInputNames (ListInputOption option) const |
List the input names. More... | |
std::vector< std::string > | ListOutputNames () const |
List the names of outputs for this symbol. More... | |
void | Compose (const array_view< const Symbol * > &args, const std::unordered_map< std::string, const Symbol * > &kwargs, const std::string &name) |
Compose the symbol with arguments, this changes the current symbol. The kwargs passed in can be in-complete,. More... | |
Symbol | operator() (const array_view< const Symbol * > &args, const std::unordered_map< std::string, const Symbol * > &kwargs, const std::string &name) const |
Apply the symbol as a function, compose with arguments. More... | |
void | AddControlDeps (const Symbol &src) |
Add control flow dependencies to the operators in symbols. More... | |
Symbol | GetInternals () const |
Symbol | GetChildren () const |
void | SetAttrs (const std::vector< std::pair< std::string, std::string > > &attrs) |
Set additional attributes to current node. More... | |
bool | GetAttr (const std::string &key, std::string *out) const |
Get attributes from the symbol. More... | |
std::unordered_map< std::string, std::string > | ListAttrs (ListAttrOption option) const |
Get attribute dictionary from the symbol. More... | |
std::vector< std::tuple< std::string, std::string, std::string > > | ListAttrsRecursive () const |
Get attribute dictionary from the symbol and all children. More... | |
Static Public Member Functions | |
static Symbol | CreateFunctor (const Op *op, std::unordered_map< std::string, std::string > attrs) |
Create symbolic functor(AtomicSymbol) by given operator and attributes. More... | |
static Symbol | CreateFunctor (const NodeAttrs &attrs) |
Create symbolic functor(AtomicSymbol) by given node attributes. More... | |
static Symbol | CreateVariable (const std::string &name) |
Create symbol node representing variable. More... | |
static Symbol | CreateGroup (const std::vector< Symbol > &symbols) |
Create equivalence of symbol by grouping the symbols together. More... | |
Public Attributes | |
std::vector< NodeEntry > | outputs |
output entries contained in the symbol More... | |
Symbol is help class used to represent the operator node in Graph.
Symbol acts as an interface for building graphs from different components like Variable, Functor and Group. Symbol is also exported to python front-end (while Graph is not) to enable quick test and deployment. Conceptually, symbol is the final operation of a graph and thus including all the information required (the graph) to evaluate its output value.
void nnvm::Symbol::AddControlDeps | ( | const Symbol & | src | ) |
Add control flow dependencies to the operators in symbols.
For grouped symbol, an error will be raised. This mutates current symbolic Node.
src | The symbols to depend on. |
void nnvm::Symbol::Compose | ( | const array_view< const Symbol * > & | args, |
const std::unordered_map< std::string, const Symbol * > & | kwargs, | ||
const std::string & | name | ||
) |
Compose the symbol with arguments, this changes the current symbol. The kwargs passed in can be in-complete,.
The rest of the symbols will remain the same name.
args | Positional arguments. |
kwargs | Keyword arguments for the symbol. |
name | Name of returned symbol. |
Symbol nnvm::Symbol::Copy | ( | ) | const |
Copy the symbol.
|
static |
Create symbolic functor(AtomicSymbol) by given operator and attributes.
op | The operator. |
attrs | The additional attributes. |
Create equivalence of symbol by grouping the symbols together.
symbols | A list of symbols to be grouped. |
|
static |
Create symbol node representing variable.
name | Name of the variable. |
bool nnvm::Symbol::GetAttr | ( | const std::string & | key, |
std::string * | out | ||
) | const |
Get attributes from the symbol.
This only works for symbol with outputs from single operators. For grouped symbol, an error will be raised.
key | Key of the attribute. When key == "name", it returns the name attirbute. |
out | The output value of the attribute. |
Symbol nnvm::Symbol::GetChildren | ( | ) | const |
Symbol nnvm::Symbol::GetInternals | ( | ) | const |
std::unordered_map<std::string, std::string> nnvm::Symbol::ListAttrs | ( | ListAttrOption | option | ) | const |
Get attribute dictionary from the symbol.
For grouped symbol, an error will be raised.
option | If recursive flag is set, the attributes of all children are retrieved. The name of symbol will be pre-pended to each key. |
std::vector<std::tuple<std::string, std::string, std::string> > nnvm::Symbol::ListAttrsRecursive | ( | ) | const |
Get attribute dictionary from the symbol and all children.
For grouped symbol, an error will be raised.
std::vector<std::string> nnvm::Symbol::ListInputNames | ( | ListInputOption | option | ) | const |
List the input names.
The order of the returned list is the same as the order of the input list to operator()
.
option | The options to list the arguments. |
std::vector<ObjectPtr> nnvm::Symbol::ListInputs | ( | ListInputOption | option | ) | const |
List the input variable nodes.
The order of the returned list is the same as the order of the input list to operator()
.
option | The options to list the arguments. |
std::vector<std::string> nnvm::Symbol::ListOutputNames | ( | ) | const |
List the names of outputs for this symbol.
For normal operators, it is usually symbol node name + "_output".
Symbol nnvm::Symbol::operator() | ( | const array_view< const Symbol * > & | args, |
const std::unordered_map< std::string, const Symbol * > & | kwargs, | ||
const std::string & | name | ||
) | const |
Apply the symbol as a function, compose with arguments.
This is equivalent to Copy then Compose.
args | Positional arguments for the symbol. |
kwargs | Keyword arguments for the symbol. |
name | Name of returned symbol. |
Symbol nnvm::Symbol::operator[] | ( | size_t | index | ) | const |
Get the index-th element from the returned tuple.
index | Index of multi output. |
void nnvm::Symbol::Print | ( | std::ostream & | os | ) | const |
Print the symbol info to output stream.
os | The output stream to print to. |
void nnvm::Symbol::SetAttrs | ( | const std::vector< std::pair< std::string, std::string > > & | attrs | ) |
Set additional attributes to current node.
This only works for symbol with outputs from single operators. For grouped symbol, an error will be raised.
This function mutates the node's symbol and is not recommended.
attrs | The attributes to set. |
std::vector<NodeEntry> nnvm::Symbol::outputs |
output entries contained in the symbol