mxnet
symbolic.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
29 #ifndef NNVM_SYMBOLIC_H_
30 #define NNVM_SYMBOLIC_H_
31 
32 #include <string>
33 #include <vector>
34 #include <tuple>
35 #include <utility>
36 #include <unordered_map>
37 
38 #include "base.h"
39 #include "node.h"
40 
41 namespace nnvm {
52  public:
56  kRecursive = 0,
58  kShallow = 1
59  };
63  kAll = 0,
65  kReadOnlyArgs = 1,
70  kAuxiliaryStates = 2
71  };
72 
74  std::vector<NodeEntry> outputs;
75 
80  Symbol Copy() const;
85  void Print(std::ostream &os) const; // NOLINT(*)
91  Symbol operator[] (size_t index) const;
101  std::vector<NodePtr> ListInputs(ListInputOption option) const;
111  std::vector<std::string> ListInputNames(ListInputOption option) const;
119  std::vector<std::string> ListOutputNames() const;
130  void Compose(const array_view<const Symbol*>& args,
131  const std::unordered_map<std::string, const Symbol*>& kwargs,
132  const std::string& name);
143  Symbol operator () (const array_view<const Symbol*>& args,
144  const std::unordered_map<std::string, const Symbol*>& kwargs,
145  const std::string& name) const;
153  void AddControlDeps(const Symbol& src);
154  /*
155  * \brief Get all the internal nodes of the symbol.
156  * \return symbol A new symbol whose output contains all the outputs of the symbols
157  * including input variables and intermediate outputs.
158  */
159  Symbol GetInternals() const;
160  /*
161  * \brief Get the direct inputs of the head node(s) of this symbol.
162  * \return symbol A new symbol whose output contains all the inputs of the head
163  * node(s).
164  */
165  Symbol GetChildren() const;
176  void SetAttrs(const std::vector<std::pair<std::string, std::string> >& attrs);
187  bool GetAttr(const std::string& key, std::string* out) const;
197  std::unordered_map<std::string, std::string> ListAttrs(ListAttrOption option) const;
205  std::vector<std::tuple<std::string, std::string, std::string> >
206  ListAttrsRecursive() const;
213  static Symbol CreateFunctor(const Op* op,
214  std::unordered_map<std::string, std::string> attrs);
220  static Symbol CreateFunctor(const NodeAttrs& attrs);
226  static Symbol CreateVariable(const std::string& name);
232  static Symbol CreateGroup(const std::vector<Symbol>& symbols);
233 };
234 
235 } // namespace nnvm
236 
237 #endif // NNVM_SYMBOLIC_H_
Read only data structure to reference continuous memory region of array. Provide unified view for vec...
Definition: array_view.h:36
Definition: base.h:36
Graph node data structure.
The attributes of the current operation node. Usually are additional parameters like axis...
Definition: node.h:120
std::vector< NodeEntry > outputs
output entries contained in the symbol
Definition: symbolic.h:74
void Copy(Tensor< cpu, dim, DType > dst, const Tensor< cpu, dim, DType > &src, Stream< cpu > *stream=NULL)
copy data from one tensor to another, with same shape
Definition: tensor_cpu-inl.h:127
ListInputOption
option passed to ListInputNames
Definition: symbolic.h:61
#define NNVM_DLL
NNVM_DLL prefix for windows.
Definition: c_api.h:38
ListAttrOption
option passed to ListAttr
Definition: symbolic.h:54
Symbol is help class used to represent the operator node in Graph.
Definition: symbolic.h:51
Configuration of nnvm as well as basic data structure.
Operator structure.
Definition: op.h:104