Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 1 | |
| 2 | // Copyright (c) 2020, ARM Limited. |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | /* |
| 17 | Syntax: |
| 18 | DEF_OPERATOR(MLIR_NAME, SCHEMA_NAME, REF_IMPL_NAME, OPTIONS, QUANT_INFO) |
| 19 | |
| 20 | Description: |
| 21 | MLIR_NAME: the symbolic string of this op, must match tosa_ops.td |
| 22 | SCHEMA_NAME: corresponding operator name, must match "enum Op" in serialization/tosa.fbs |
| 23 | REF_IMPL_NAME: name used internally in tosa reference implementation |
| 24 | OPTIONS: compile time constant options of this op, corresponding to operator_option.def |
| 25 | QUANT_INFO: quantization infomation of this op, corresponding to quant_info.def |
| 26 | */ |
| 27 | |
| 28 | |
| 29 | /* tensor operators */ |
| 30 | DEF_OPERATOR(argmax, ARGMAX, ArgMax, Axis, None) |
| 31 | DEF_OPERATOR(avg_pool2d, AVG_POOL2D, AvgPool2d, Pool2d, Unary) |
| 32 | DEF_OPERATOR(conv2d, CONV2D, Conv2d, Conv2d, Conv) |
| 33 | DEF_OPERATOR(conv3d, CONV3D, Conv3d, None, None) |
| 34 | DEF_OPERATOR(depthwise_conv2d, DEPTHWISE_CONV2D, DepthwiseConv2d, Conv2d, Conv) |
| 35 | DEF_OPERATOR(fully_connected, FULLY_CONNECTED, FullyConnected, None, Conv) |
| 36 | DEF_OPERATOR(matmul, MATMUL, MatMul, None, MatMul) |
| 37 | DEF_OPERATOR(max_pool2d, MAX_POOL2D, MaxPool2d, Pool2d, None) |
| 38 | DEF_OPERATOR(transpose_conv2d, TRANSPOSE_CONV2D, TransposeConv2d, TransposeConv2d, Conv) |
| 39 | |
| 40 | /* activation */ |
| 41 | DEF_OPERATOR(clamp, CLAMP, Clamp, Clamp, None) |
| 42 | DEF_OPERATOR(reluN, RELUN, ReluN, ReluN, None) |
| 43 | DEF_OPERATOR(sigmoid, SIGMOID, Sigmoid, None, None) |
| 44 | DEF_OPERATOR(tanh, TANH, Tanh, None, None) |
| 45 | |
| 46 | /* elementwise - binary */ |
| 47 | DEF_OPERATOR(add, ADD, Add, None, None) |
| 48 | DEF_OPERATOR(arithmetic_right_shift, ARITHMETIC_RIGHT_SHIFT, ArithmeticRightShift, None, None) |
| 49 | DEF_OPERATOR(bitwise_and, BITWISE_AND, BitwiseAnd, None, None) |
| 50 | DEF_OPERATOR(bitwise_or, BITWISE_OR, BitwiseOr, None, None) |
| 51 | DEF_OPERATOR(bitwise_xor, BITWISE_XOR, BitwiseXor, None, None) |
| 52 | DEF_OPERATOR(logical_and, LOGICAL_AND, LogicalAnd, None, None) |
| 53 | DEF_OPERATOR(logical_left_shift, LOGICAL_LEFT_SHIFT, LogicalLeftShift, None, None) |
| 54 | DEF_OPERATOR(logical_right_shift, LOGICAL_RIGHT_SHIFT, LogicalRightShift, None, None) |
| 55 | DEF_OPERATOR(logical_or, LOGICAL_OR, LogicalOr, None, None) |
| 56 | DEF_OPERATOR(logical_xor, LOGICAL_XOR, LogicalXor, None, None) |
| 57 | DEF_OPERATOR(maximum, MAXIMUM, Maximum, None, None) |
| 58 | DEF_OPERATOR(minimum, MINIMUM, Minimum, None, None) |
| 59 | DEF_OPERATOR(mul, MUL, Mul, None, None) |
| 60 | DEF_OPERATOR(pow, POW, Pow, None, None) |
| 61 | DEF_OPERATOR(sub, SUB, Sub, None, None) |
| 62 | DEF_OPERATOR(table, TABLE, Table, None, None) |
| 63 | |
| 64 | /* elementwise - unary */ |
| 65 | DEF_OPERATOR(abs, ABS, Abs, None, None) |
| 66 | DEF_OPERATOR(bitwise_not, BITWISE_NOT, BitwiseNot, None, None) |
| 67 | DEF_OPERATOR(ceil, CEIL, Ceil, None, None) |
| 68 | DEF_OPERATOR(clz, CLZ, Clz, None, None) |
| 69 | DEF_OPERATOR(exp, EXP, Exp, None, None) |
| 70 | DEF_OPERATOR(floor, FLOOR, Floor, None, None) |
| 71 | DEF_OPERATOR(log, LOG, Log, None, None) |
| 72 | DEF_OPERATOR(logical_not, LOGICAL_NOT, LogicalNot, None, None) |
| 73 | DEF_OPERATOR(negate, NEGATE, Negate, None, Unary) |
| 74 | DEF_OPERATOR(reciprocal, RECIPROCAL, Reciprocal, None, None) |
| 75 | DEF_OPERATOR(rsqrt, RSQRT, Rsqrt, None, None) |
| 76 | |
| 77 | /* elementwise - ternary */ |
| 78 | DEF_OPERATOR(select, SELECT, Select, None, None) |
| 79 | |
| 80 | /* logical */ |
| 81 | DEF_OPERATOR(equal, EQUAL, Equal, None, None) |
| 82 | DEF_OPERATOR(greater, GREATER, Greater, None, None) |
| 83 | DEF_OPERATOR(greater_equal, GREATER_EQUAL, GreaterEqual, None, None) |
| 84 | |
| 85 | /* reduction */ |
| 86 | DEF_OPERATOR(reduce_any, REDUCE_ANY, ReduceAny, Reduce, None) |
| 87 | DEF_OPERATOR(reduce_all, REDUCE_ALL, ReduceAll, Reduce, None) |
| 88 | DEF_OPERATOR(reduce_max, REDUCE_MAX, ReduceMax, Reduce, None) |
| 89 | DEF_OPERATOR(reduce_min, REDUCE_MIN, ReduceMin, Reduce, None) |
| 90 | DEF_OPERATOR(reduce_prod, REDUCE_PRODUCT, ReduceProduct, Reduce, None) |
| 91 | DEF_OPERATOR(reduce_sum, REDUCE_SUM, ReduceSum, Reduce, None) |
| 92 | |
| 93 | /* memory operation */ |
| 94 | DEF_OPERATOR(concat, CONCAT, Concat, Axis, None) |
| 95 | DEF_OPERATOR(pad, PAD, Pad, None, Pad) |
| 96 | DEF_OPERATOR(reshape, RESHAPE, Reshape, Reshape, None) |
| 97 | DEF_OPERATOR(reverse, REVERSE, Reverse, Reverse, None) |
| 98 | DEF_OPERATOR(slice, SLICE, Slice, Slice, None) |
| 99 | DEF_OPERATOR(tile, TILE, Tile, Tile, None) |
| 100 | DEF_OPERATOR(transpose, TRANSPOSE, Transpose, None, None) |
| 101 | |
| 102 | /* gather/scatter */ |
| 103 | DEF_OPERATOR(gather, GATHER, Gather, Axis, None) |
| 104 | |
| 105 | /* image */ |
| 106 | DEF_OPERATOR(resize, RESIZE, Resize, Resize, None) |
| 107 | |
| 108 | /* quantization */ |
| 109 | DEF_OPERATOR(cast, CAST, Cast, None, None) |
| 110 | DEF_OPERATOR(rescale, RESCALE, Rescale, Rescale, None) |
| 111 | |
| 112 | /* data nodes */ |
| 113 | DEF_OPERATOR(const, CONST, Const, None, None) |
| 114 | DEF_OPERATOR(placeholder, PLACEHOLDER, Placeholder, None, None) |
| 115 | DEF_OPERATOR(identity, IDENTITY, Identity, None, None) |
| 116 | DEF_OPERATOR(identityn, IDENTITYN, IdentityN, None, None) |
| 117 | |
| 118 | /* custom operations */ |
| 119 | DEF_OPERATOR(custom, CUSTOM, Custom, None, None) |
| 120 | |
| 121 | /* control flow operators */ |
| 122 | DEF_OPERATOR(cond_if, COND_IF, CondIf, CondIf, None) |
| 123 | DEF_OPERATOR(while_loop, WHILE_LOOP, WhileLoop, WhileLoop, None) |