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 
28 #ifndef NNVM_SYMBOLIC_H_
29 #define NNVM_SYMBOLIC_H_
30 
31 #include <string>
32 #include <vector>
33 #include <tuple>
34 #include <utility>
35 #include <unordered_map>
36 
37 #include "base.h"
38 #include "node.h"
39 
40 namespace nnvm {
51  public:
55  kRecursive = 0,
57  kShallow = 1
58  };
62  kAll = 0,
64  kReadOnlyArgs = 1,
69  kAuxiliaryStates = 2
70  };
71 
73  std::vector<NodeEntry> outputs;
74 
79  Symbol Copy() const;
84  void Print(std::ostream &os) const; // NOLINT(*)
90  Symbol operator[] (size_t index) const;
100  std::vector<ObjectPtr> ListInputs(ListInputOption option) const;
110  std::vector<std::string> ListInputNames(ListInputOption option) const;
118  std::vector<std::string> ListOutputNames() const;
129  void Compose(const array_view<const Symbol*>& args,
130  const std::unordered_map<std::string, const Symbol*>& kwargs,
131  const std::string& name);
142  Symbol operator () (const array_view<const Symbol*>& args,
143  const std::unordered_map<std::string, const Symbol*>& kwargs,
144  const std::string& name) const;
152  void AddControlDeps(const Symbol& src);
153  /*
154  * \brief Get all the internal nodes of the symbol.
155  * \return symbol A new symbol whose output contains all the outputs of the symbols
156  * including input variables and intermediate outputs.
157  */
158  Symbol GetInternals() const;
159  /*
160  * \brief Get the direct inputs of the head node(s) of this symbol.
161  * \return symbol A new symbol whose output contains all the inputs of the head
162  * node(s).
163  */
164  Symbol GetChildren() const;
175  void SetAttrs(const std::vector<std::pair<std::string, std::string> >& attrs);
186  bool GetAttr(const std::string& key, std::string* out) const;
196  std::unordered_map<std::string, std::string> ListAttrs(ListAttrOption option) const;
204  std::vector<std::tuple<std::string, std::string, std::string> >
205  ListAttrsRecursive() const;
212  static Symbol CreateFunctor(const Op* op,
213  std::unordered_map<std::string, std::string> attrs);
219  static Symbol CreateFunctor(const NodeAttrs& attrs);
225  static Symbol CreateVariable(const std::string& name);
231  static Symbol CreateGroup(const std::vector<Symbol>& symbols);
232 };
233 
234 } // namespace nnvm
235 
236 #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:35
The attributes of the current operation node. Usually are additional parameters like axis...
Definition: node.h:119
std::vector< NodeEntry > outputs
output entries contained in the symbol
Definition: symbolic.h:73
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:146
Graph node data structure.
ListInputOption
option passed to ListInputNames
Definition: symbolic.h:60
#define NNVM_DLL
NNVM_DLL prefix for windows.
Definition: c_api.h:37
ListAttrOption
option passed to ListAttr
Definition: symbolic.h:53
Symbol is help class used to represent the operator node in Graph.
Definition: symbolic.h:50
Configuration of nnvm as well as basic data structure.
Operator structure.
Definition: op.h:103