mxnet
op_attr_types.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 
25 #ifndef NNVM_COMPILER_OP_ATTR_TYPES_H_
26 #define NNVM_COMPILER_OP_ATTR_TYPES_H_
27 
28 #include <tvm/expr.h>
29 #include <tvm/tensor.h>
30 #include <tvm/schedule.h>
31 #include <tvm/packed_func_ext.h>
32 #include <tvm/runtime/registry.h>
33 #include <nnvm/op_attr_types.h>
34 #include <nnvm/graph_attr_types.h>
35 #include <nnvm/graph.h>
36 #include <vector>
37 #include <string>
38 #include "packed_func_ext.h"
39 
40 namespace nnvm {
41 namespace compiler {
42 
43 using ::tvm::Array;
44 using ::tvm::Tensor;
45 using ::tvm::Schedule;
46 
49  // Elementwise operation
50  kElemWise = 0,
51  // Broadcasting operator, can always map output axis to the input in order.
52  // for example :code:`out[i, ax1, j, ax2] = input[i, j]`.
53  // Note that the axis need to be in order so transpose is not a bcast operator.
55  // Injective operator, can always injectively map output axis to a single input axis.
56  // All injective operator can still be safely fused to injective and reduction.
58  // Communicative reduction operator.
60  // Complex operation, can still fuse elemwise operations into its output.
61  // but cannot chain another complex op
63  // Opaque operation, cannot fuse anything.
64  kOpaque = 8
65 };
66 
68 using TOpPattern = int;
69 
78 using FTVMCompute = std::function<
79  Array<Tensor>(const NodeAttrs& attrs,
80  const Array<Tensor>& inputs,
81  const Array<Tensor>& out_info)>;
82 
91 using FTVMSchedule = std::function<
92  Schedule(const NodeAttrs& attrs,
93  const Array<Tensor>& outs,
94  const std::string& target)>;
95 
105 using FTVMAlterOpLayout = std::function<
106  bool(const NodeAttrs& attrs,
107  const Symbol& inputs,
108  const Array<Tensor>& tinfos,
109  Symbol* ret)>;
110 
116 using FTVMVectorizedOp = std::function<nnvm::NodePtr (const nnvm::Node* node)>;
117 
118 } // namespace compiler
119 } // namespace nnvm
120 #endif // NNVM_COMPILER_OP_ATTR_TYPES_H_
Definition: base.h:36
Definition: op_attr_types.h:57
The attributes of the current operation node. Usually are additional parameters like axis...
Definition: node.h:120
Definition: op_attr_types.h:62
std::function< bool(const NodeAttrs &attrs, const Symbol &inputs, const Array< Tensor > &tinfos, Symbol *ret)> FTVMAlterOpLayout
Modify the op node to alter its input layout. it is invoked in AlterOpLayout pass.
Definition: op_attr_types.h:109
std::function< Array< Tensor >(const NodeAttrs &attrs, const Array< Tensor > &inputs, const Array< Tensor > &out_info)> FTVMCompute
Computation description interface.
Definition: op_attr_types.h:81
Definition: op_attr_types.h:50
Data structures that can appear in graph attributes.
Definition: op_attr_types.h:64
Extension to enable packed functionn for nnvm types.
Configuation of nnvm as well as basic data structure.
int TOpPattern
the operator pattern
Definition: op_attr_types.h:68
Definition: op_attr_types.h:54
Definition: op_attr_types.h:59
std::function< Schedule(const NodeAttrs &attrs, const Array< Tensor > &outs, const std::string &target)> FTVMSchedule
Build the computation schedule for op whose root is at current op.
Definition: op_attr_types.h:94
OpPatternKind
operator pattern used in graph fusion
Definition: op_attr_types.h:48
std::function< nnvm::NodePtr(const nnvm::Node *node)> FTVMVectorizedOp
Transform from normal operator to vectorized operator.
Definition: op_attr_types.h:116
Data structures that can appear in operator attributes.
Symbol is help class used to represent the operator node in Graph.
Definition: symbolic.h:51