2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __TFLITE_OP_REGISTRY_H__
18 #define __TFLITE_OP_REGISTRY_H__
20 #include "TFliteOpChef.h"
21 #include "TFliteOpChefs.h"
29 * @brief tflchef operator registry
31 class TFliteOpRegistry
35 * @brief Returns registered TFliteOpChef pointer for BuiltinOperator or
36 * nullptr if not registered
38 const TFliteOpChef *lookup(tflite::BuiltinOperator op) const
40 if (_tfliteop_map.find(op) == _tfliteop_map.end())
43 return _tfliteop_map.at(op).get();
46 static TFliteOpRegistry &get()
48 static TFliteOpRegistry me;
55 #define REG_TFL_OP(OPCODE, CLASS) \
56 _tfliteop_map[tflite::BuiltinOperator_##OPCODE] = std::make_unique<CLASS>()
58 REG_TFL_OP(ABS, TFliteOpAbs);
59 REG_TFL_OP(ADD, TFliteOpAdd);
60 REG_TFL_OP(ADD_N, TFliteOpAddN);
61 REG_TFL_OP(ARG_MAX, TFliteOpArgMax);
62 REG_TFL_OP(ARG_MIN, TFliteOpArgMin);
63 REG_TFL_OP(AVERAGE_POOL_2D, TFliteOpAveragePool2D);
64 REG_TFL_OP(BATCH_MATMUL, TFliteOpBatchMatMul);
65 REG_TFL_OP(BATCH_TO_SPACE_ND, TFliteOpBatchToSpaceND);
66 REG_TFL_OP(BIDIRECTIONAL_SEQUENCE_LSTM, TFliteOpBidirectionalSequenceLSTM);
67 REG_TFL_OP(CAST, TFliteOpCast);
68 REG_TFL_OP(CEIL, TFliteOpCeil);
69 REG_TFL_OP(CONCATENATION, TFliteOpConcatenation);
70 REG_TFL_OP(CONV_2D, TFliteOpConv2D);
71 REG_TFL_OP(COS, TFliteOpCos);
72 REG_TFL_OP(DEPTH_TO_SPACE, TFliteOpDepthToSpace);
73 REG_TFL_OP(DEPTHWISE_CONV_2D, TFliteOpDepthwiseConv2D);
74 REG_TFL_OP(DEQUANTIZE, TFliteOpDequantize);
75 REG_TFL_OP(DIV, TFliteOpDiv);
76 REG_TFL_OP(ELU, TFliteOpELU);
77 REG_TFL_OP(EQUAL, TFliteOpEqual);
78 REG_TFL_OP(EXP, TFliteOpExp);
79 REG_TFL_OP(EXPAND_DIMS, TFliteOpExpandDims);
80 REG_TFL_OP(FAKE_QUANT, TFliteOpFakeQuant);
81 REG_TFL_OP(FILL, TFliteOpFill);
82 REG_TFL_OP(FLOOR, TFliteOpFloor);
83 REG_TFL_OP(FLOOR_DIV, TFliteOpFloorDiv);
84 REG_TFL_OP(FLOOR_MOD, TFliteOpFloorMod);
85 REG_TFL_OP(FULLY_CONNECTED, TFliteOpFullyConnected);
86 REG_TFL_OP(GATHER, TFliteOpGather);
87 REG_TFL_OP(GATHER_ND, TFliteOpGatherNd);
88 REG_TFL_OP(GREATER, TFliteOpGreater);
89 REG_TFL_OP(GREATER_EQUAL, TFliteOpGreaterEqual);
90 REG_TFL_OP(L2_NORMALIZATION, TFliteOpL2Normalize);
91 REG_TFL_OP(L2_POOL_2D, TFliteOpL2Pool2D);
92 REG_TFL_OP(LEAKY_RELU, TFliteOpLeakyRelu);
93 REG_TFL_OP(LESS, TFliteOpLess);
94 REG_TFL_OP(LESS_EQUAL, TFliteOpLessEqual);
95 REG_TFL_OP(LOCAL_RESPONSE_NORMALIZATION, TFliteOpLocalResponseNormalization);
96 REG_TFL_OP(LOG, TFliteOpLog);
97 REG_TFL_OP(LOGICAL_AND, TFliteOpLogicalAnd);
98 REG_TFL_OP(LOGICAL_NOT, TFliteOpLogicalNot);
99 REG_TFL_OP(LOGICAL_OR, TFliteOpLogicalOr);
100 REG_TFL_OP(LOGISTIC, TFliteOpLogistic);
101 REG_TFL_OP(LOG_SOFTMAX, TFliteOpLogSoftmax);
102 REG_TFL_OP(MATRIX_DIAG, TFliteOpMatrixDiag);
103 REG_TFL_OP(MAX_POOL_2D, TFliteOpMaxPool2D);
104 REG_TFL_OP(MATRIX_SET_DIAG, TFliteOpMatrixSetDiag);
105 REG_TFL_OP(MAXIMUM, TFliteOpMaximum);
106 REG_TFL_OP(MEAN, TFliteOpMean);
107 REG_TFL_OP(MINIMUM, TFliteOpMinimum);
108 REG_TFL_OP(MIRROR_PAD, TFliteOpMirrorPad);
109 REG_TFL_OP(MUL, TFliteOpMul);
110 REG_TFL_OP(NEG, TFliteOpNeg);
111 REG_TFL_OP(NON_MAX_SUPPRESSION_V4, TFliteOpNonMaxSuppressionV4);
112 REG_TFL_OP(NON_MAX_SUPPRESSION_V5, TFliteOpNonMaxSuppressionV5);
113 REG_TFL_OP(NOT_EQUAL, TFliteOpNotEqual);
114 REG_TFL_OP(ONE_HOT, TFliteOpOneHot);
115 REG_TFL_OP(PACK, TFliteOpPack);
116 REG_TFL_OP(PAD, TFliteOpPad);
117 REG_TFL_OP(PADV2, TFliteOpPadV2);
118 REG_TFL_OP(POW, TFliteOpPow);
119 REG_TFL_OP(PRELU, TFliteOpPRelu);
120 REG_TFL_OP(QUANTIZE, TFliteOpQuantize);
121 REG_TFL_OP(RANGE, TFliteOpRange);
122 REG_TFL_OP(RANK, TFliteOpRank);
123 REG_TFL_OP(REDUCE_ANY, TFliteOpReduceAny);
124 REG_TFL_OP(REDUCE_MAX, TFliteOpReduceMax);
125 REG_TFL_OP(REDUCE_MIN, TFliteOpReduceMin);
126 REG_TFL_OP(REDUCE_PROD, TFliteOpReduceProd);
127 REG_TFL_OP(RELU, TFliteOpReLU);
128 REG_TFL_OP(RELU6, TFliteOpReLU6);
129 REG_TFL_OP(RELU_N1_TO_1, TFliteOpReLUN1To1);
130 REG_TFL_OP(RESHAPE, TFliteOpReshape);
131 REG_TFL_OP(RESIZE_BILINEAR, TFliteOpResizeBilinear);
132 REG_TFL_OP(RESIZE_NEAREST_NEIGHBOR, TFliteOpResizeNearestNeighbor);
133 REG_TFL_OP(REVERSE_SEQUENCE, TFliteOpReverseSequence);
134 REG_TFL_OP(REVERSE_V2, TFliteOpReverseV2);
135 REG_TFL_OP(ROUND, TFliteOpRound);
136 REG_TFL_OP(RSQRT, TFliteOpRsqrt);
137 REG_TFL_OP(SCATTER_ND, TFliteOpScatterNd);
138 REG_TFL_OP(SEGMENT_SUM, TFliteOpSegmentSum);
139 REG_TFL_OP(SELECT, TFliteOpSelect);
140 REG_TFL_OP(SELECT_V2, TFliteOpSelectV2);
141 REG_TFL_OP(SHAPE, TFliteOpShape);
142 REG_TFL_OP(SIN, TFliteOpSin);
143 REG_TFL_OP(SLICE, TFliteOpSlice);
144 REG_TFL_OP(SOFTMAX, TFliteOpSoftmax);
145 REG_TFL_OP(SPACE_TO_BATCH_ND, TFliteOpSpaceToBatchND);
146 REG_TFL_OP(SPACE_TO_DEPTH, TFliteOpSpaceToDepth);
147 REG_TFL_OP(SPARSE_TO_DENSE, TFliteOpSparseToDense);
148 REG_TFL_OP(SPLIT, TFliteOpSplit);
149 REG_TFL_OP(SPLIT_V, TFliteOpSplitV);
150 REG_TFL_OP(SQRT, TFliteOpSqrt);
151 REG_TFL_OP(SQUARE, TFliteOpSquare);
152 REG_TFL_OP(SQUARED_DIFFERENCE, TFliteOpSquaredDifference);
153 REG_TFL_OP(SQUEEZE, TFliteOpSqueeze);
154 REG_TFL_OP(STRIDED_SLICE, TFliteOpStridedSlice);
155 REG_TFL_OP(SUB, TFliteOpSub);
156 REG_TFL_OP(SUM, TFliteOpSum);
157 REG_TFL_OP(SVDF, TFliteOpSVDF);
158 REG_TFL_OP(TANH, TFliteOpTanh);
159 REG_TFL_OP(TILE, TFliteOpTile);
160 REG_TFL_OP(TOPK_V2, TFliteOpTopKV2);
161 REG_TFL_OP(TRANSPOSE, TFliteOpTranspose);
162 REG_TFL_OP(TRANSPOSE_CONV, TFliteOpTransposeConv);
163 REG_TFL_OP(UNIDIRECTIONAL_SEQUENCE_LSTM, TFliteOpUnidirectionalSequenceLSTM);
164 REG_TFL_OP(UNIQUE, TFliteOpUnique);
165 REG_TFL_OP(UNPACK, TFliteOpUnpack);
166 REG_TFL_OP(WHERE, TFliteOpWhere);
167 REG_TFL_OP(ZEROS_LIKE, TFliteOpZerosLike);
173 std::map<tflite::BuiltinOperator, std::unique_ptr<TFliteOpChef>> _tfliteop_map;
176 } // namespace tflchef
178 #endif // __TFLITE_OP_REGISTRY_H__