Go to the documentation of this file.
29 #include <unordered_map>
84 return std::hash<Node*>()(e.
node.get()) ^ (std::hash<size_t>()(e.
index) << 1 >> 1) ^
85 (std::hash<size_t>()(e.
version) << 1);
100 template <
typename ValueType>
101 using NodeEntryMap = std::unordered_map<NodeEntry, ValueType, NodeEntryHash, NodeEntryEqual>;
116 std::unordered_map<std::string, std::string>
dict;
146 Node(
const Op* op,
const std::string& name) {
148 this->attrs.
name = name;
164 inline const Op* op()
const;
170 inline bool is_variable()
const;
172 inline uint32_t num_outputs()
const;
174 inline uint32_t num_inputs()
const;
179 template <
class... Args>
181 return std::make_shared<Node>(std::forward<Args>(args)...);
193 inline NodeEntry MakeNode(
const char* op_name, std::string node_name, std::vector<NodeEntry> inputs,
194 std::unordered_map<std::string, std::string> attrs =
195 std::unordered_map<std::string, std::string>()) {
198 p->attrs.name = std::move(node_name);
199 p->attrs.dict = attrs;
200 if (p->attrs.op->attr_parser) {
201 p->attrs.op->attr_parser(&(p->attrs));
203 p->inputs = std::move(inputs);
214 if (this->
op()->get_num_outputs ==
nullptr) {
223 if (this->
op()->get_num_inputs ==
nullptr) {
232 #endif // NNVM_NODE_H_
std::string name
name of the node
Definition: node.h:114
bool is_variable() const
return whether node is placeholder variable. This is equivalent to op == nullptr
Definition: node.h:210
std::function< uint32_t(const NodeAttrs &attrs)> get_num_inputs
get number of inputs given information about the node.
Definition: op.h:149
uint32_t num_inputs
number of inputs to the operator, -1 means it is variable length When get_num_inputs is presented,...
Definition: op.h:123
NodeEntry(ObjectPtr node, uint32_t index, uint32_t version)
Definition: node.h:53
const Op * op() const
Definition: node.h:208
size_t operator()(const NodeEntry &a, const NodeEntry &b) const
Definition: node.h:94
Node represents an operation in a computation graph.
Definition: node.h:143
std::string name
name of the operator
Definition: op.h:108
This lets you use a NodeEntry as a key in a unordered_map of the form unordered_map<NodeEntry,...
Definition: node.h:82
NodeEntry()
Definition: node.h:62
NodeEntry MakeNode(const char *op_name, std::string node_name, std::vector< NodeEntry > inputs, std::unordered_map< std::string, std::string > attrs=std::unordered_map< std::string, std::string >())
Quick utilities make node.
Definition: node.h:193
uint32_t num_outputs() const
Definition: node.h:212
const Op * op
The operator this node uses. For place holder variable, op == nullptr.
Definition: node.h:112
Node(const Op *op, const std::string &name)
Definition: node.h:146
std::vector< NodeEntry > inputs
inputs to this node
Definition: node.h:153
uint32_t index
index of output from the source.
Definition: node.h:67
uint32_t version
version of input Variable. This field can only be nonzero when this->node is a Variable node....
Definition: node.h:75
static const Op * Get(const std::string &op_name)
Get an Op for a given operator name. Will raise an error if the op has not been registered.
Operator information structor.
NodeAttrs attrs
The attributes in the node.
Definition: node.h:151
std::unordered_map< std::string, std::string > dict
The dictionary representation of attributes.
Definition: node.h:116
static ObjectPtr Create(Args &&... args)
create a new empty shared_ptr of Node.
Definition: node.h:180
Configuration of nnvm as well as basic data structure.
std::unordered_map< NodeEntry, ValueType, NodeEntryHash, NodeEntryEqual > NodeEntryMap
Definition: node.h:101
The attributes of the current operation node. Usually are additional parameters like axis,...
Definition: node.h:107
std::shared_ptr< Node > ObjectPtr
we always used ObjectPtr for a reference pointer to the node, so this alias can be changed in case.
Definition: node.h:49
std::vector< std::shared_ptr< Symbol > > subgraphs
Some operators take graphs as input. These operators include control flow operators and high-order fu...
Definition: node.h:137
size_t operator()(const NodeEntry &e) const
Definition: node.h:83
C API of NNVM symbolic construction and pass. Enables construction and transformation of Graph in any...
any info
additional fields for this node
Definition: node.h:160
uint32_t num_inputs() const
Definition: node.h:221
Definition: optional.h:251
an entry that represents output data from a node
Definition: node.h:52
std::function< uint32_t(const NodeAttrs &attrs)> get_num_outputs
get number of outputs given information about the node.
Definition: op.h:143
#define NNVM_DLL
NNVM_DLL prefix for windows.
Definition: c_api.h:37
ObjectPtr node
the source node of this data
Definition: node.h:65
Operator structure.
Definition: op.h:105
This lets you use a NodeEntry as a key in a unordered_map of the form unordered_map<NodeEntry,...
Definition: node.h:93
any parsed
A parsed version of attributes, This is generated if OpProperty.attr_parser is registered....
Definition: node.h:122
uint32_t num_outputs
number of outputs of the operator When get_num_outputs is presented. The number of outputs will be de...
Definition: op.h:131
std::vector< ObjectPtr > control_deps
Optional control flow dependencies Gives operation must be performed before this operation.
Definition: node.h:158
NodeEntry(ObjectPtr node)
Definition: node.h:56