mxnet
|
Namespaces | |
pass | |
Classes | |
class | Graph |
Symbolic computation graph. This is the intermediate representation for optimization pass. More... | |
class | IndexedGraph |
Auxiliary data structure to index a graph. It maps Nodes in the graph to consecutive integers node_id. It also maps IndexedGraph::NodeEntry to consecutive integer entry_id. This allows storing properties of Node and NodeEntry into compact vector and quickly access them without resorting to hashmap. More... | |
class | Layout |
class | Node |
Node represents an operation in a computation graph. More... | |
struct | NodeAttrs |
The attributes of the current operation node. Usually are additional parameters like axis,. More... | |
struct | NodeEntry |
an entry that represents output data from a node More... | |
struct | NodeEntryEqual |
This lets you use a NodeEntry as a key in a unordered_map of the form unordered_map<NodeEntry, ValueType, NodeEntryHash, NodeEntryEqual> More... | |
struct | NodeEntryHash |
This lets you use a NodeEntry as a key in a unordered_map of the form unordered_map<NodeEntry, ValueType, NodeEntryHash, NodeEntryEqual> More... | |
class | Op |
Operator structure. More... | |
class | OpGroup |
auxiliary data structure used to set attributes to a group of operators More... | |
class | OpMap |
A map data structure that takes Op* as key and returns ValueType. More... | |
struct | PassFunctionReg |
Registry entry for pass functions. More... | |
class | Symbol |
Symbol is help class used to represent the operator node in Graph. More... | |
class | TShape |
A Shape class that is used to represent shape of each tensor. More... | |
class | Tuple |
A dynamic sized array data structure that is optimized for storing small number of elements with same type. More... | |
Typedefs | |
using | JSONString = std::string |
The result holder of JSON serializer. More... | |
using | ShapeVector = std::vector< TShape > |
The result holder of shape of each NodeEntry in the graph. More... | |
using | DTypeVector = std::vector< int > |
The result holder of type of each NodeEntry in the graph. More... | |
using | LayoutVector = std::vector< Layout > |
The result holder of layout of each NodeEntry in the graph. More... | |
using | DeviceVector = std::vector< int > |
The result holder of device of each operator in the graph. More... | |
using | DeviceAssignMap = std::unordered_map< std::string, int > |
The result holder of device of each operator in the graph. More... | |
using | StorageVector = std::vector< int > |
The result holder of storage id of each NodeEntry in the graph. More... | |
using | ObjectPtr = std::shared_ptr< Node > |
we always used ObjectPtr for a reference pointer to the node, so this alias can be changed in case. More... | |
template<typename ValueType > | |
using | NodeEntryMap = std::unordered_map< NodeEntry, ValueType, NodeEntryHash, NodeEntryEqual > |
using | FListInputNames = std::function< std::vector< std::string >(const NodeAttrs &attrs)> |
Return list of input arguments names of each operator. More... | |
using | FNumVisibleOutputs = std::function< uint32_t(const NodeAttrs &attrs)> |
Return number of visible outputs by the user. More... | |
using | FListOutputNames = std::function< std::vector< std::string >(const NodeAttrs &attrs)> |
Return list of output arguments names of each operator. More... | |
using | FMutateInputs = std::function< std::vector< uint32_t >(const NodeAttrs &attrs)> |
Check whether operator will mutate k-th input. More... | |
template<typename AttrType > | |
using | FInferNodeEntryAttr = std::function< bool(const NodeAttrs &attrs, std::vector< AttrType > *in_attrs, std::vector< AttrType > *out_attrs)> |
Inference function of certain type. More... | |
using | FGetAttrDict = std::function< std::unordered_map< std::string, std::string >(const NodeAttrs &attrs)> |
Get attribute dictionary from node. More... | |
using | FInferShape = FInferNodeEntryAttr< TShape > |
Shape inference function. Update the shapes given the input shape information. TShape.ndim() == 0 means the shape is still unknown. More... | |
using | FInferType = FInferNodeEntryAttr< int > |
Type inference function. Update the type given the known type information. More... | |
using | TIsBackward = bool |
Whether this op is an explicit backward operator, If TIsBackward is true: More... | |
using | TIsGhost = bool |
Whether this op is a ghost node. If TIsGhost is true: More... | |
using | FInplaceOption = std::function< std::vector< std::pair< int, int > >(const NodeAttrs &attrs)> |
Get possible inplace options. This function enables optimization to reuse memory of inputs in output. More... | |
using | FInplaceIdentity = std::function< std::vector< bool >(const NodeAttrs &attrs)> |
Get if the inplace option is an identity This function enables inplace optimization even when input reference count is greater than one. More... | |
using | FIgnoreInputs = std::function< std::vector< uint32_t >(const NodeAttrs &attrs)> |
Get list of inputs in the op whose content are actually not used by the operator These are dummy input that can be used for example in zeros_like, ones_like. More... | |
using | FGradient = std::function< std::vector< NodeEntry >(const ObjectPtr &nodeptr, const std::vector< NodeEntry > &out_grads)> |
Get the gradient node of the op node This function generates the backward graph of the node. More... | |
using | FSetInputVarAttrOnCompose = std::function< void(const NodeAttrs &attrs, ObjectPtr var, const int index)> |
Set the attributes of input variable. Usually used for setting initialization or weight decay. More... | |
using | FCorrectLayout = std::function< bool(const NodeAttrs &attrs, std::vector< Layout > *ilayouts, const std::vector< Layout > *last_ilayouts, std::vector< Layout > *olayouts)> |
Infer & correct function of node layout. See Layout for layout convention. More... | |
using | FInputGraph = std::function< std::vector< uint32_t >(const NodeAttrs &attrs)> |
Get a list of inputs that represent graphs instead of data. Normally, input symbols are considered as data to the operator. However, control flow operators and high-order functions need to interpret symbols as graphs. More... | |
typedef std::function< Graph(Graph src)> | PassFunction |
A PassFunction is an "Operator on Graph". It takes a source graph and return a graph that may or may not be the same as the input one. More... | |
typedef int64_t | dim_t |
data type to store dim size More... | |
Enumerations | |
enum | TypeFlag { kFloat32 = 0, kFloat64 = 1, kFloat16 = 2, kUint8 = 3, kInt32 = 4, kInt8 = 5, kInt64 = 6, kInt16 = 8, kUint16 = 9, kUint32 = 10, kUint64 = 11, kBfloat16 = 12 } |
Functions | |
template<typename FVisit > | |
void | DFSVisit (const std::vector< NodeEntry > &heads, FVisit fvisit) |
perform a Post Order DFS visit to each node in the graph. This order is deterministic and is also topoligical sorted. More... | |
template<typename GNode , typename HashType , typename FVisit , typename HashFunc , typename InDegree , typename GetInput > | |
void | PostOrderDFSVisit (const std::vector< GNode > &heads, FVisit fvisit, HashFunc hash, InDegree indegree, GetInput getinput) |
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. More... | |
Graph | ApplyPasses (Graph src, const std::vector< std::string > &passes) |
Apply a series of pass transformations on the input graph. More... | |
Graph | ApplyPass (Graph src, const std::string &pass) |
Apply one pass to the graph. More... | |
template<typename SrcIter , typename DstIter > | |
DstIter | ShapeTypeCast (const SrcIter begin, const SrcIter end, DstIter dst_begin) |
helper function to cast type of container elements More... | |
template<typename SrcIter > | |
TShape | ShapeTypeCast (const SrcIter begin, const SrcIter end) |
helper function to transform a container to TShape with type cast More... | |
using nnvm::DeviceAssignMap = typedef std::unordered_map<std::string, int> |
The result holder of device of each operator in the graph.
using nnvm::DeviceVector = typedef std::vector<int> |
The result holder of device of each operator in the graph.
typedef int64_t nnvm::dim_t |
data type to store dim size
using nnvm::DTypeVector = typedef std::vector<int> |
The result holder of type of each NodeEntry in the graph.
using nnvm::FCorrectLayout = typedef std::function<bool( const NodeAttrs& attrs, std::vector<Layout> *ilayouts, const std::vector<Layout> *last_ilayouts, std::vector<Layout> *olayouts)> |
Infer & correct function of node layout. See Layout
for layout convention.
attrs | The attribute of the node. |
ilayouts | Given the input layouts produced by ancestor nodes, it should be filled by layouts that the node requests. If the requested layout is different from what ancestor produces, a layout_transform operator will be inserted automatically. |
last_ilayouts | The input layouts requested by the node at the last infer pass (if any). This can be useful when an operator wants to keep the input layout the same as the original one. For example, after the pass of AlterOpLayout, transpose(input, axis=[1, 2, 3, 0]) may receive an input of NCHW16c layout, with which it cannot calculate with axis=[1, 2, 3, 0]. Last input layouts allow it to know what the layout it originally inferred, i.e., the layout in the imported model. |
olayouts | Inferred output layouts. |
using nnvm::FGetAttrDict = typedef std::function< std::unordered_map<std::string, std::string> (const NodeAttrs& attrs)> |
Get attribute dictionary from node.
attrs | The attributes of the node. |
using nnvm::FGradient = typedef std::function<std::vector<NodeEntry>( const ObjectPtr& nodeptr, const std::vector<NodeEntry>& out_grads)> |
Get the gradient node of the op node This function generates the backward graph of the node.
nodeptr | The node to take gradient |
out_grads | Gradient of current node's outputs |
using nnvm::FIgnoreInputs = typedef std::function< std::vector<uint32_t> (const NodeAttrs& attrs)> |
Get list of inputs in the op whose content are actually not used by the operator These are dummy input that can be used for example in zeros_like, ones_like.
attrs | The attributes of the node |
using nnvm::FInferNodeEntryAttr = typedef std::function<bool (const NodeAttrs& attrs, std::vector<AttrType> *in_attrs, std::vector<AttrType> *out_attrs)> |
Inference function of certain type.
AttrType | The type of the attribute to be infered. |
using nnvm::FInferShape = typedef FInferNodeEntryAttr<TShape> |
Shape inference function. Update the shapes given the input shape information. TShape.ndim() == 0 means the shape is still unknown.
FInferShape is needed by shape inference
using nnvm::FInferType = typedef FInferNodeEntryAttr<int> |
Type inference function. Update the type given the known type information.
using nnvm::FInplaceIdentity = typedef std::function<std::vector<bool> (const NodeAttrs& attrs)> |
Get if the inplace option is an identity This function enables inplace optimization even when input reference count is greater than one.
attrs | The attributes of the node |
using nnvm::FInplaceOption = typedef std::function< std::vector<std::pair<int, int> > (const NodeAttrs& attrs)> |
Get possible inplace options. This function enables optimization to reuse memory of inputs in output.
attrs | The attributes of the node |
using nnvm::FInputGraph = typedef std::function<std::vector<uint32_t>(const NodeAttrs& attrs)> |
Get a list of inputs that represent graphs instead of data. Normally, input symbols are considered as data to the operator. However, control flow operators and high-order functions need to interpret symbols as graphs.
attrs | The attributes of this node. |
using nnvm::FListInputNames = typedef std::function<std::vector<std::string> (const NodeAttrs& attrs)> |
Return list of input arguments names of each operator.
attrs | The attributes of the node. |
FListInputNames enables automatic variable creation for missing arguments.
using nnvm::FListOutputNames = typedef std::function<std::vector<std::string> (const NodeAttrs& attrs)> |
Return list of output arguments names of each operator.
attrs | The attributes of the node. |
FListOutputNames customized naming for operator outputs.
using nnvm::FMutateInputs = typedef std::function<std::vector<uint32_t> (const NodeAttrs& attrs)> |
Check whether operator will mutate k-th input.
attrs | The attributes of the node. |
using nnvm::FNumVisibleOutputs = typedef std::function<uint32_t (const NodeAttrs& attrs)> |
Return number of visible outputs by the user.
attrs | The attributes of the node. |
using nnvm::FSetInputVarAttrOnCompose = typedef std::function<void( const NodeAttrs& attrs, ObjectPtr var, const int index)> |
Set the attributes of input variable. Usually used for setting initialization or weight decay.
attrs | The attributes of this node. |
var | the input variable |
index | index of var in all inputs |
using nnvm::JSONString = typedef std::string |
The result holder of JSON serializer.
using nnvm::LayoutVector = typedef std::vector<Layout> |
The result holder of layout of each NodeEntry in the graph.
using nnvm::NodeEntryMap = typedef std::unordered_map<NodeEntry, ValueType, NodeEntryHash, NodeEntryEqual> |
use NodeEntry as key in unordered_map
using nnvm::ObjectPtr = typedef std::shared_ptr<Node> |
we always used ObjectPtr for a reference pointer to the node, so this alias can be changed in case.
By default, ObjectPtr is a std::shared_ptr of node
typedef std::function<Graph (Graph src)> nnvm::PassFunction |
A PassFunction is an "Operator on Graph". It takes a source graph and return a graph that may or may not be the same as the input one.
A pass function can either change the graph structure (thus, generating a new Graph), or add new attributes to the graph.
src | The graph to be transformed. |
using nnvm::ShapeVector = typedef std::vector<TShape> |
The result holder of shape of each NodeEntry in the graph.
using nnvm::StorageVector = typedef std::vector<int> |
The result holder of storage id of each NodeEntry in the graph.
using nnvm::TIsBackward = typedef bool |
Whether this op is an explicit backward operator, If TIsBackward is true:
using nnvm::TIsGhost = typedef bool |
Whether this op is a ghost node. If TIsGhost is true:
enum nnvm::TypeFlag |
Apply one pass to the graph.
src | The graph to be transformed. |
pass | The name of pass to be applied. |
Apply a series of pass transformations on the input graph.
src | The graph to be transformed. |
passes | A list of pass names to be applied. |
|
inline |
perform a Post Order DFS visit to each node in the graph. This order is deterministic and is also topoligical sorted.
heads | The heads in the graph. |
fvisit | a function of type std::function<void(const std::shared_ptr<Node>&)> |
FVisit | The function type to perform the visit. |
|
inline |
Quick utilities make node.
op_name | The name of operator |
node_name | The name of the node |
inputs | The input entries |
attrs | The attributes |
void nnvm::PostOrderDFSVisit | ( | const std::vector< GNode > & | heads, |
FVisit | fvisit, | ||
HashFunc | hash, | ||
InDegree | indegree, | ||
GetInput | getinput | ||
) |
|
inline |
helper function to cast type of container elements