1 | /* Copyright 2018 The TensorFlow Authors. All Rights Reserved. |
2 | |
3 | Licensed under the Apache License, Version 2.0 (the "License"); |
4 | you may not use this file except in compliance with the License. |
5 | You may obtain a copy of the License at |
6 | |
7 | http://www.apache.org/licenses/LICENSE-2.0 |
8 | |
9 | Unless required by applicable law or agreed to in writing, software |
10 | distributed under the License is distributed on an "AS IS" BASIS, |
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | See the License for the specific language governing permissions and |
13 | limitations under the License. |
14 | ==============================================================================*/ |
15 | |
16 | #include "tensorflow/lite/kernels/register_ref.h" |
17 | |
18 | #include "tensorflow/lite/c/common.h" |
19 | #include "tensorflow/lite/mutable_op_resolver.h" |
20 | #include "tensorflow/lite/schema/schema_generated.h" |
21 | #include "tensorflow/lite/util.h" |
22 | |
23 | namespace tflite { |
24 | namespace ops { |
25 | |
26 | namespace custom { |
27 | |
28 | TfLiteRegistration* Register_NUMERIC_VERIFY_REF(); |
29 | TfLiteRegistration* Register_AUDIO_SPECTROGRAM(); |
30 | TfLiteRegistration* Register_MFCC(); |
31 | TfLiteRegistration* Register_DETECTION_POSTPROCESS(); |
32 | |
33 | } // namespace custom |
34 | |
35 | namespace builtin { |
36 | |
37 | // TODO(yunluli): Some of the registries, e.g. Tanh(), could only invoke |
38 | // optimized kernels. Add a _REF() variant for them. |
39 | TfLiteRegistration* Register_ABS(); |
40 | TfLiteRegistration* Register_RELU(); |
41 | TfLiteRegistration* Register_RELU_N1_TO_1(); |
42 | TfLiteRegistration* Register_RELU_0_TO_1(); |
43 | TfLiteRegistration* Register_RELU6(); |
44 | TfLiteRegistration* Register_TANH_REF(); |
45 | TfLiteRegistration* Register_LOGISTIC_REF(); |
46 | TfLiteRegistration* Register_AVERAGE_POOL_REF(); |
47 | TfLiteRegistration* Register_MAX_POOL_REF(); |
48 | TfLiteRegistration* Register_L2_POOL_REF(); |
49 | TfLiteRegistration* Register_CONVOLUTION_REF(); |
50 | TfLiteRegistration* Register_DEPTHWISE_CONVOLUTION_REF(); |
51 | TfLiteRegistration* Register_SVDF(); |
52 | TfLiteRegistration* Register_RNN(); |
53 | TfLiteRegistration* Register_BIDIRECTIONAL_SEQUENCE_RNN(); |
54 | TfLiteRegistration* Register_UNIDIRECTIONAL_SEQUENCE_RNN(); |
55 | TfLiteRegistration* Register_EMBEDDING_LOOKUP(); |
56 | TfLiteRegistration* Register_EMBEDDING_LOOKUP_SPARSE(); |
57 | TfLiteRegistration* Register_FULLY_CONNECTED_REF(); |
58 | TfLiteRegistration* Register_LSH_PROJECTION(); |
59 | TfLiteRegistration* Register_HASHTABLE_LOOKUP(); |
60 | TfLiteRegistration* Register_SOFTMAX_REF(); |
61 | TfLiteRegistration* Register_CONCATENATION_REF(); |
62 | TfLiteRegistration* Register_ADD_REF(); |
63 | TfLiteRegistration* Register_SPACE_TO_BATCH_ND_REF(); |
64 | TfLiteRegistration* Register_DIV_REF(); |
65 | TfLiteRegistration* Register_SUB_REF(); |
66 | TfLiteRegistration* Register_BATCH_TO_SPACE_ND_REF(); |
67 | TfLiteRegistration* Register_MUL_REF(); |
68 | TfLiteRegistration* Register_L2NORM_REF(); |
69 | TfLiteRegistration* Register_LOCAL_RESPONSE_NORM_REF(); |
70 | TfLiteRegistration* Register_LSTM(); |
71 | TfLiteRegistration* Register_BIDIRECTIONAL_SEQUENCE_LSTM(); |
72 | TfLiteRegistration* Register_UNIDIRECTIONAL_SEQUENCE_LSTM(); |
73 | TfLiteRegistration* Register_PAD_REF(); |
74 | TfLiteRegistration* Register_PADV2_REF(); |
75 | TfLiteRegistration* Register_RESHAPE(); |
76 | TfLiteRegistration* Register_RESIZE_BILINEAR_REF(); |
77 | TfLiteRegistration* Register_RESIZE_NEAREST_NEIGHBOR_REF(); |
78 | TfLiteRegistration* Register_SKIP_GRAM(); |
79 | TfLiteRegistration* Register_SPACE_TO_DEPTH_REF(); |
80 | TfLiteRegistration* Register_GATHER(); |
81 | TfLiteRegistration* Register_TRANSPOSE_REF(); |
82 | TfLiteRegistration* Register_MEAN_REF(); |
83 | TfLiteRegistration* Register_SPLIT(); |
84 | TfLiteRegistration* Register_SPLIT_V(); |
85 | TfLiteRegistration* Register_SQUEEZE(); |
86 | TfLiteRegistration* Register_STRIDED_SLICE_REF(); |
87 | TfLiteRegistration* Register_EXP_REF(); |
88 | TfLiteRegistration* Register_TOPK_V2(); |
89 | TfLiteRegistration* Register_LOG(); |
90 | TfLiteRegistration* Register_LOG_SOFTMAX_REF(); |
91 | TfLiteRegistration* Register_CAST(); |
92 | TfLiteRegistration* Register_DEQUANTIZE_REF(); |
93 | TfLiteRegistration* Register_PRELU_REF(); |
94 | TfLiteRegistration* Register_MAXIMUM_REF(); |
95 | TfLiteRegistration* Register_MINIMUM_REF(); |
96 | TfLiteRegistration* Register_ARG_MAX(); |
97 | TfLiteRegistration* Register_ARG_MIN(); |
98 | TfLiteRegistration* Register_GREATER(); |
99 | TfLiteRegistration* Register_GREATER_EQUAL(); |
100 | TfLiteRegistration* Register_LESS(); |
101 | TfLiteRegistration* Register_LESS_EQUAL(); |
102 | TfLiteRegistration* Register_FLOOR_REF(); |
103 | TfLiteRegistration* Register_TILE(); |
104 | TfLiteRegistration* Register_NEG(); |
105 | TfLiteRegistration* Register_SUM_REF(); |
106 | TfLiteRegistration* Register_REDUCE_PROD_REF(); |
107 | TfLiteRegistration* Register_REDUCE_MAX_REF(); |
108 | TfLiteRegistration* Register_REDUCE_MIN_REF(); |
109 | TfLiteRegistration* Register_REDUCE_ANY_REF(); |
110 | TfLiteRegistration* Register_REDUCE_ALL_REF(); |
111 | TfLiteRegistration* Register_SELECT(); |
112 | TfLiteRegistration* Register_SLICE_REF(); |
113 | TfLiteRegistration* Register_SIN(); |
114 | TfLiteRegistration* Register_COS(); |
115 | TfLiteRegistration* Register_TRANSPOSECONV_REF(); |
116 | TfLiteRegistration* Register_EXPAND_DIMS(); |
117 | TfLiteRegistration* Register_SPARSE_TO_DENSE(); |
118 | TfLiteRegistration* Register_EQUAL(); |
119 | TfLiteRegistration* Register_NOT_EQUAL(); |
120 | TfLiteRegistration* Register_SQRT(); |
121 | TfLiteRegistration* Register_RSQRT(); |
122 | TfLiteRegistration* Register_SHAPE(); |
123 | TfLiteRegistration* Register_RANK(); |
124 | TfLiteRegistration* Register_POW(); |
125 | TfLiteRegistration* Register_FAKE_QUANT_REF(); |
126 | TfLiteRegistration* Register_PACK(); |
127 | TfLiteRegistration* Register_ONE_HOT(); |
128 | TfLiteRegistration* Register_LOGICAL_OR(); |
129 | TfLiteRegistration* Register_LOGICAL_AND(); |
130 | TfLiteRegistration* Register_LOGICAL_NOT(); |
131 | TfLiteRegistration* Register_UNPACK(); |
132 | TfLiteRegistration* Register_FLOOR_DIV(); |
133 | TfLiteRegistration* Register_SQUARE(); |
134 | TfLiteRegistration* Register_ZEROS_LIKE(); |
135 | TfLiteRegistration* Register_FLOOR_MOD(); |
136 | TfLiteRegistration* Register_RANGE(); |
137 | TfLiteRegistration* Register_LEAKY_RELU_REF(); |
138 | TfLiteRegistration* Register_SQUARED_DIFFERENCE(); |
139 | TfLiteRegistration* Register_FILL(); |
140 | TfLiteRegistration* Register_MIRROR_PAD(); |
141 | TfLiteRegistration* Register_UNIQUE(); |
142 | TfLiteRegistration* Register_REVERSE_V2(); |
143 | TfLiteRegistration* Register_ADD_N(); |
144 | TfLiteRegistration* Register_GATHER_ND(); |
145 | TfLiteRegistration* Register_WHERE(); |
146 | TfLiteRegistration* Register_REVERSE_SEQUENCE(); |
147 | TfLiteRegistration* Register_MATRIX_DIAG(); |
148 | TfLiteRegistration* Register_QUANTIZE_REF(); |
149 | TfLiteRegistration* Register_MATRIX_SET_DIAG(); |
150 | TfLiteRegistration* Register_IF(); |
151 | TfLiteRegistration* Register_WHILE(); |
152 | TfLiteRegistration* Register_NON_MAX_SUPPRESSION_V4(); |
153 | TfLiteRegistration* Register_NON_MAX_SUPPRESSION_V5(); |
154 | TfLiteRegistration* Register_SCATTER_ND(); |
155 | TfLiteRegistration* Register_DENSIFY(); |
156 | TfLiteRegistration* Register_BATCH_MATMUL_REF(); |
157 | TfLiteRegistration* Register_HARD_SWISH_REF(); |
158 | TfLiteRegistration* Register_DEPTH_TO_SPACE_REF(); |
159 | TfLiteRegistration* Register_SELECT_V2(); |
160 | TfLiteRegistration* Register_SEGMENT_SUM(); |
161 | TfLiteRegistration* Register_BROADCAST_TO(); |
162 | TfLiteRegistration* Register_CONV_3D_REF(); |
163 | TfLiteRegistration* Register_IMAG(); |
164 | TfLiteRegistration* Register_REAL(); |
165 | TfLiteRegistration* Register_COMPLEX_ABS(); |
166 | TfLiteRegistration* Register_CONV_3D_TRANSPOSE_REF(); |
167 | TfLiteRegistration* Register_BROADCAST_ARGS(); |
168 | TfLiteRegistration* Register_RANDOM_STANDARD_NORMAL(); |
169 | TfLiteRegistration* Register_BUCKETIZE(); |
170 | TfLiteRegistration* Register_RANDOM_UNIFORM(); |
171 | TfLiteRegistration* Register_MULTINOMIAL(); |
172 | TfLiteRegistration* Register_GELU(); |
173 | TfLiteRegistration* Register_DYNAMIC_UPDATE_SLICE(); |
174 | TfLiteRegistration* Register_UNSORTED_SEGMENT_PROD(); |
175 | TfLiteRegistration* Register_UNSORTED_SEGMENT_MAX(); |
176 | TfLiteRegistration* Register_UNSORTED_SEGMENT_MIN(); |
177 | TfLiteRegistration* Register_UNSORTED_SEGMENT_SUM(); |
178 | TfLiteRegistration* Register_ATAN2(); |
179 | TfLiteRegistration* Register_SIGN(); |
180 | |
181 | namespace { |
182 | |
183 | TfLiteStatus UnsupportedTensorFlowOp(TfLiteContext* context, TfLiteNode* node) { |
184 | TF_LITE_KERNEL_LOG( |
185 | context, |
186 | "Regular TensorFlow ops are not supported by this interpreter. Make sure " |
187 | "you invoke the Flex delegate before inference." ); |
188 | return kTfLiteError; |
189 | } |
190 | |
191 | } // namespace |
192 | |
193 | const TfLiteRegistration* BuiltinRefOpResolver::FindOp( |
194 | tflite::BuiltinOperator op, int version) const { |
195 | return MutableOpResolver::FindOp(op, version); |
196 | } |
197 | |
198 | const TfLiteRegistration* BuiltinRefOpResolver::FindOp(const char* op, |
199 | int version) const { |
200 | // Return the NULL Op for all ops whose name start with "Flex", allowing |
201 | // the interpreter to delegate their execution. |
202 | if (IsFlexOp(op)) { |
203 | static TfLiteRegistration null_op{ |
204 | nullptr, nullptr, &UnsupportedTensorFlowOp, |
205 | nullptr, nullptr, BuiltinOperator_CUSTOM, |
206 | "Flex" , 1}; |
207 | return &null_op; |
208 | } |
209 | return MutableOpResolver::FindOp(op, version); |
210 | } |
211 | |
212 | BuiltinRefOpResolver::BuiltinRefOpResolver() { |
213 | AddBuiltin(BuiltinOperator_ABS, Register_ABS(), /* min_version = */ 1, |
214 | /* max_version = */ 3); |
215 | AddBuiltin(BuiltinOperator_HARD_SWISH, Register_HARD_SWISH_REF()); |
216 | AddBuiltin(BuiltinOperator_RELU, Register_RELU(), /* min_version = */ 1, |
217 | /* max_version = */ 3); |
218 | AddBuiltin(BuiltinOperator_RELU_N1_TO_1, Register_RELU_N1_TO_1()); |
219 | AddBuiltin(BuiltinOperator_RELU_0_TO_1, Register_RELU_0_TO_1()); |
220 | AddBuiltin(BuiltinOperator_RELU6, Register_RELU6(), /* min_version = */ 1, |
221 | /* max_version = */ 3); |
222 | AddBuiltin(BuiltinOperator_TANH, Register_TANH_REF(), /* min_version = */ 1, |
223 | /* max_version = */ 3); |
224 | AddBuiltin(BuiltinOperator_LOGISTIC, Register_LOGISTIC_REF(), |
225 | /* min_version = */ 1, |
226 | /* max_version = */ 3); |
227 | AddBuiltin(BuiltinOperator_AVERAGE_POOL_2D, Register_AVERAGE_POOL_REF(), |
228 | /* min_version = */ 1, |
229 | /* max_version = */ 3); |
230 | AddBuiltin(BuiltinOperator_MAX_POOL_2D, Register_MAX_POOL_REF(), |
231 | /* min_version = */ 1, |
232 | /* max_version = */ 3); |
233 | AddBuiltin(BuiltinOperator_L2_POOL_2D, Register_L2_POOL_REF()); |
234 | AddBuiltin(BuiltinOperator_CONV_2D, Register_CONVOLUTION_REF(), |
235 | /* min_version = */ 1, |
236 | /* max_version = */ 6); |
237 | AddBuiltin(BuiltinOperator_DEPTHWISE_CONV_2D, |
238 | Register_DEPTHWISE_CONVOLUTION_REF(), |
239 | /* min_version = */ 1, |
240 | /* max_version = */ 6); |
241 | AddBuiltin(BuiltinOperator_SVDF, Register_SVDF(), |
242 | /* min_version = */ 1, |
243 | /* max_version = */ 4); |
244 | AddBuiltin(BuiltinOperator_RNN, Register_RNN(), |
245 | /* min_version = */ 1, |
246 | /* max_version = */ 3); |
247 | AddBuiltin(BuiltinOperator_BIDIRECTIONAL_SEQUENCE_RNN, |
248 | Register_BIDIRECTIONAL_SEQUENCE_RNN(), |
249 | /* min_version = */ 1, |
250 | /* max_version = */ 3); |
251 | AddBuiltin(BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_RNN, |
252 | Register_UNIDIRECTIONAL_SEQUENCE_RNN(), |
253 | /* min_version = */ 1, |
254 | /* max_version = */ 3); |
255 | AddBuiltin(BuiltinOperator_EMBEDDING_LOOKUP, Register_EMBEDDING_LOOKUP(), |
256 | /* min_version = */ 1, |
257 | /* max_version = */ 3); |
258 | AddBuiltin(BuiltinOperator_EMBEDDING_LOOKUP_SPARSE, |
259 | Register_EMBEDDING_LOOKUP_SPARSE()); |
260 | AddBuiltin(BuiltinOperator_FULLY_CONNECTED, Register_FULLY_CONNECTED_REF(), |
261 | /* min_version */ 1, |
262 | /* max_version */ 9); |
263 | AddBuiltin(BuiltinOperator_LSH_PROJECTION, Register_LSH_PROJECTION()); |
264 | AddBuiltin(BuiltinOperator_HASHTABLE_LOOKUP, Register_HASHTABLE_LOOKUP()); |
265 | AddBuiltin(BuiltinOperator_SOFTMAX, Register_SOFTMAX_REF(), |
266 | /* min_version = */ 1, |
267 | /* max_version = */ 3); |
268 | AddBuiltin(BuiltinOperator_CONCATENATION, Register_CONCATENATION_REF(), |
269 | /* min_version = */ 1, |
270 | /* max_version = */ 3); |
271 | AddBuiltin(BuiltinOperator_ADD, Register_ADD_REF(), |
272 | /* min_version */ 1, |
273 | /* max_version */ 4); |
274 | AddBuiltin(BuiltinOperator_SPACE_TO_BATCH_ND, |
275 | Register_SPACE_TO_BATCH_ND_REF(), |
276 | /* min_version = */ 1, |
277 | /* max_version = */ 3); |
278 | AddBuiltin(BuiltinOperator_BATCH_TO_SPACE_ND, |
279 | Register_BATCH_TO_SPACE_ND_REF(), |
280 | /* min_version = */ 1, |
281 | /* max_version = */ 3); |
282 | AddBuiltin(BuiltinOperator_MUL, Register_MUL_REF(), /* min_version = */ 1, |
283 | /* max_version = */ 6); |
284 | AddBuiltin(BuiltinOperator_L2_NORMALIZATION, Register_L2NORM_REF(), |
285 | /* min_version = */ 1, |
286 | /* max_version = */ 2); |
287 | // The version one of broadcast to op won't be not supported since the version |
288 | // one was rollbacked and the builtin op code number has been changed because |
289 | // of builtin op code shortage problem. |
290 | AddBuiltin(BuiltinOperator_BROADCAST_TO, Register_BROADCAST_TO(), |
291 | /* min_version = */ 2, |
292 | /* max_version = */ 3); |
293 | AddBuiltin(BuiltinOperator_LOCAL_RESPONSE_NORMALIZATION, |
294 | Register_LOCAL_RESPONSE_NORM_REF()); |
295 | AddBuiltin(BuiltinOperator_LSTM, Register_LSTM(), /* min_version */ 1, |
296 | /* max_version */ 4); |
297 | AddBuiltin(BuiltinOperator_BIDIRECTIONAL_SEQUENCE_LSTM, |
298 | Register_BIDIRECTIONAL_SEQUENCE_LSTM(), /* min_version */ 1, |
299 | /* max_version */ 3); |
300 | AddBuiltin(BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_LSTM, |
301 | Register_UNIDIRECTIONAL_SEQUENCE_LSTM(), /* min_version = */ 1, |
302 | /* max_version = */ 3); |
303 | AddBuiltin(BuiltinOperator_PAD, Register_PAD_REF(), /* min_version = */ 1, |
304 | /* max_version = */ 4); |
305 | AddBuiltin(BuiltinOperator_PADV2, Register_PADV2_REF(), /* min_version = */ 1, |
306 | /* max_version = */ 4); |
307 | AddBuiltin(BuiltinOperator_RESHAPE, Register_RESHAPE()); |
308 | AddBuiltin(BuiltinOperator_RESIZE_BILINEAR, Register_RESIZE_BILINEAR_REF(), |
309 | /* min_version = */ 1, |
310 | /* max_version = */ 4); |
311 | AddBuiltin(BuiltinOperator_RESIZE_NEAREST_NEIGHBOR, |
312 | Register_RESIZE_NEAREST_NEIGHBOR_REF(), |
313 | /* min_version = */ 1, |
314 | /* max_version = */ 4); |
315 | AddBuiltin(BuiltinOperator_SKIP_GRAM, Register_SKIP_GRAM()); |
316 | AddBuiltin(BuiltinOperator_SPACE_TO_DEPTH, Register_SPACE_TO_DEPTH_REF(), |
317 | /* min_version = */ 1, |
318 | /* max_version = */ 2); |
319 | AddBuiltin(BuiltinOperator_DEPTH_TO_SPACE, Register_DEPTH_TO_SPACE_REF()); |
320 | AddBuiltin(BuiltinOperator_GATHER, Register_GATHER(), |
321 | /* min_version = */ 1, |
322 | /* max_version = */ 4); |
323 | AddBuiltin(BuiltinOperator_TRANSPOSE, Register_TRANSPOSE_REF(), |
324 | /* min_version = */ 1, |
325 | /* max_version = */ 5); |
326 | AddBuiltin(BuiltinOperator_MEAN, Register_MEAN_REF(), |
327 | /* min_version = */ 1, |
328 | /* max_version = */ 3); |
329 | AddBuiltin(BuiltinOperator_DIV, Register_DIV_REF(), |
330 | /* min_version = */ 1, |
331 | /* max_version = */ 2); |
332 | AddBuiltin(BuiltinOperator_SUB, Register_SUB_REF(), |
333 | /* min_version = */ 1, |
334 | /* max_version = */ 5); |
335 | AddBuiltin(BuiltinOperator_SPLIT, Register_SPLIT(), |
336 | /* min_version = */ 1, |
337 | /* max_version = */ 4); |
338 | AddBuiltin(BuiltinOperator_SPLIT_V, Register_SPLIT_V(), |
339 | /* min_version = */ 1, |
340 | /* max_version = */ 2); |
341 | AddBuiltin(BuiltinOperator_SQUEEZE, Register_SQUEEZE()); |
342 | AddBuiltin(BuiltinOperator_STRIDED_SLICE, Register_STRIDED_SLICE_REF(), |
343 | /* min_version = */ 1, |
344 | /* max_version = */ 4); |
345 | AddBuiltin(BuiltinOperator_EXP, Register_EXP_REF()); |
346 | AddBuiltin(BuiltinOperator_TOPK_V2, Register_TOPK_V2(), |
347 | /* min_version = */ 1, |
348 | /* max_version = */ 2); |
349 | AddBuiltin(BuiltinOperator_LOG, Register_LOG()); |
350 | AddBuiltin(BuiltinOperator_LOG_SOFTMAX, Register_LOG_SOFTMAX_REF(), |
351 | /* min_version = */ 1, |
352 | /* max_version = */ 2); |
353 | AddBuiltin(BuiltinOperator_CAST, Register_CAST(), |
354 | /* min_version = */ 1, |
355 | /* max_version = */ 4); |
356 | AddBuiltin(BuiltinOperator_DEQUANTIZE, Register_DEQUANTIZE_REF(), |
357 | /* min_version = */ 1, |
358 | /* max_version = */ 4); |
359 | AddBuiltin(BuiltinOperator_PRELU, Register_PRELU_REF()); |
360 | AddBuiltin(BuiltinOperator_MAXIMUM, Register_MAXIMUM_REF(), |
361 | /* min_version = */ 1, |
362 | /* max_version = */ 4); |
363 | AddBuiltin(BuiltinOperator_MINIMUM, Register_MINIMUM_REF(), |
364 | /* min_version = */ 1, |
365 | /* max_version = */ 4); |
366 | AddBuiltin(BuiltinOperator_ARG_MAX, Register_ARG_MAX(), |
367 | /* min_version = */ 1, |
368 | /* max_version = */ 2); |
369 | AddBuiltin(BuiltinOperator_ARG_MIN, Register_ARG_MIN(), |
370 | /* min_version = */ 1, |
371 | /* max_version = */ 2); |
372 | AddBuiltin(BuiltinOperator_GREATER, Register_GREATER(), |
373 | /* min_version = */ 1, |
374 | /* max_version = */ 2); |
375 | AddBuiltin(BuiltinOperator_GREATER_EQUAL, Register_GREATER_EQUAL(), |
376 | /* min_version = */ 1, |
377 | /* max_version = */ 2); |
378 | AddBuiltin(BuiltinOperator_LESS, Register_LESS(), |
379 | /* min_version = */ 1, |
380 | /* max_version = */ 2); |
381 | AddBuiltin(BuiltinOperator_LESS_EQUAL, Register_LESS_EQUAL(), |
382 | /* min_version = */ 1, |
383 | /* max_version = */ 2); |
384 | AddBuiltin(BuiltinOperator_FLOOR, Register_FLOOR_REF()); |
385 | AddBuiltin(BuiltinOperator_NEG, Register_NEG()); |
386 | AddBuiltin(BuiltinOperator_SELECT, Register_SELECT(), |
387 | /* min_version = */ 1, |
388 | /* max_version = */ 2); |
389 | AddBuiltin(BuiltinOperator_SELECT_V2, Register_SELECT_V2()); |
390 | AddBuiltin(BuiltinOperator_SLICE, Register_SLICE_REF(), |
391 | /* min_version = */ 1, |
392 | /* max_version = */ 5); |
393 | AddBuiltin(BuiltinOperator_SIN, Register_SIN()); |
394 | AddBuiltin(BuiltinOperator_COS, Register_COS()); |
395 | AddBuiltin(BuiltinOperator_TRANSPOSE_CONV, Register_TRANSPOSECONV_REF(), |
396 | /* min_version = */ 1, |
397 | /* max_version = */ 3); |
398 | AddBuiltin(BuiltinOperator_TILE, Register_TILE(), |
399 | /* min_version = */ 1, |
400 | /* max_version = */ 2); |
401 | AddBuiltin(BuiltinOperator_SUM, Register_SUM_REF(), |
402 | /* min_version = */ 1, |
403 | /* max_version = */ 2); |
404 | AddBuiltin(BuiltinOperator_REDUCE_PROD, Register_REDUCE_PROD_REF(), |
405 | /* min_version = */ 1, |
406 | /* max_version = */ 2); |
407 | AddBuiltin(BuiltinOperator_REDUCE_MAX, Register_REDUCE_MAX_REF(), |
408 | /* min_version = */ 1, |
409 | /* max_version = */ 3); |
410 | AddBuiltin(BuiltinOperator_REDUCE_MIN, Register_REDUCE_MIN_REF(), |
411 | /* min_version = */ 1, |
412 | /* max_version = */ 3); |
413 | AddBuiltin(BuiltinOperator_REDUCE_ANY, Register_REDUCE_ANY_REF()); |
414 | AddBuiltin(BuiltinOperator_REDUCE_ALL, Register_REDUCE_ALL_REF()); |
415 | AddBuiltin(BuiltinOperator_EXPAND_DIMS, Register_EXPAND_DIMS()); |
416 | AddBuiltin(BuiltinOperator_SPARSE_TO_DENSE, Register_SPARSE_TO_DENSE(), |
417 | /* min_version = */ 1, |
418 | /* max_version = */ 3); |
419 | AddBuiltin(BuiltinOperator_EQUAL, Register_EQUAL(), |
420 | /* min_version = */ 1, |
421 | /* max_version = */ 3); |
422 | AddBuiltin(BuiltinOperator_NOT_EQUAL, Register_NOT_EQUAL(), |
423 | /* min_version = */ 1, |
424 | /* max_version = */ 3); |
425 | AddBuiltin(BuiltinOperator_SQRT, Register_SQRT()); |
426 | AddBuiltin(BuiltinOperator_RSQRT, Register_RSQRT(), |
427 | /* min_version = */ 1, |
428 | /* max_version = */ 2); |
429 | AddBuiltin(BuiltinOperator_SHAPE, Register_SHAPE()); |
430 | AddBuiltin(BuiltinOperator_RANK, Register_RANK()); |
431 | AddBuiltin(BuiltinOperator_POW, Register_POW()); |
432 | AddBuiltin(BuiltinOperator_FAKE_QUANT, Register_FAKE_QUANT_REF(), |
433 | /* min_version = */ 1, |
434 | /* max_version = */ 2); |
435 | AddBuiltin(BuiltinOperator_PACK, Register_PACK(), |
436 | /* min_version = */ 1, |
437 | /* max_version = */ 3); |
438 | AddBuiltin(BuiltinOperator_ONE_HOT, Register_ONE_HOT()); |
439 | AddBuiltin(BuiltinOperator_LOGICAL_OR, Register_LOGICAL_OR()); |
440 | AddBuiltin(BuiltinOperator_LOGICAL_AND, Register_LOGICAL_AND()); |
441 | AddBuiltin(BuiltinOperator_LOGICAL_NOT, Register_LOGICAL_NOT()); |
442 | AddBuiltin(BuiltinOperator_UNPACK, Register_UNPACK(), |
443 | /* min_version = */ 1, |
444 | /* max_version = */ 4); |
445 | AddBuiltin(BuiltinOperator_FLOOR_DIV, Register_FLOOR_DIV(), |
446 | /* min_version = */ 1, |
447 | /* max_version = */ 2); |
448 | AddBuiltin(BuiltinOperator_SQUARE, Register_SQUARE()); |
449 | AddBuiltin(BuiltinOperator_ZEROS_LIKE, Register_ZEROS_LIKE()); |
450 | AddBuiltin(BuiltinOperator_FLOOR_MOD, Register_FLOOR_MOD()); |
451 | AddBuiltin(BuiltinOperator_RANGE, Register_RANGE()); |
452 | AddBuiltin(BuiltinOperator_LEAKY_RELU, Register_LEAKY_RELU_REF(), |
453 | /* min_version = */ 1, |
454 | /* max_version = */ 2); |
455 | AddBuiltin(BuiltinOperator_SQUARED_DIFFERENCE, Register_SQUARED_DIFFERENCE(), |
456 | /* min_version = */ 1, |
457 | /* max_version = */ 2); |
458 | AddBuiltin(BuiltinOperator_FILL, Register_FILL(), |
459 | /* min_version = */ 1, |
460 | /* max_version = */ 3); |
461 | AddBuiltin(BuiltinOperator_MIRROR_PAD, Register_MIRROR_PAD(), |
462 | /* min_version = */ 1, |
463 | /* max_version = */ 2); |
464 | AddBuiltin(BuiltinOperator_UNIQUE, Register_UNIQUE()); |
465 | AddBuiltin(BuiltinOperator_REVERSE_V2, Register_REVERSE_V2(), |
466 | /* min_version = */ 1, |
467 | /* max_version = */ 2); |
468 | AddBuiltin(BuiltinOperator_ADD_N, Register_ADD_N()); |
469 | AddBuiltin(BuiltinOperator_GATHER_ND, Register_GATHER_ND(), |
470 | /* min_version = */ 1, |
471 | /* max_version = */ 3); |
472 | AddBuiltin(BuiltinOperator_WHERE, Register_WHERE(), /* min_version = */ 1, |
473 | /* max_version = */ 2); |
474 | AddBuiltin(BuiltinOperator_REVERSE_SEQUENCE, Register_REVERSE_SEQUENCE()); |
475 | AddBuiltin(BuiltinOperator_MATRIX_DIAG, Register_MATRIX_DIAG()); |
476 | AddBuiltin(BuiltinOperator_QUANTIZE, Register_QUANTIZE_REF(), |
477 | /* min_version = */ 1, |
478 | /* max_version = */ 2); |
479 | AddBuiltin(BuiltinOperator_MATRIX_SET_DIAG, Register_MATRIX_SET_DIAG()); |
480 | AddBuiltin(BuiltinOperator_IF, Register_IF()); |
481 | AddBuiltin(BuiltinOperator_WHILE, Register_WHILE()); |
482 | AddBuiltin(BuiltinOperator_NON_MAX_SUPPRESSION_V4, |
483 | Register_NON_MAX_SUPPRESSION_V4()); |
484 | AddBuiltin(BuiltinOperator_NON_MAX_SUPPRESSION_V5, |
485 | Register_NON_MAX_SUPPRESSION_V5()); |
486 | AddBuiltin(BuiltinOperator_SCATTER_ND, Register_SCATTER_ND()); |
487 | AddBuiltin(BuiltinOperator_DENSIFY, Register_DENSIFY()); |
488 | AddBuiltin(BuiltinOperator_BATCH_MATMUL, Register_BATCH_MATMUL_REF(), |
489 | /* min_version = */ 1, |
490 | /* max_version = */ 3); |
491 | AddBuiltin(BuiltinOperator_CONV_3D, Register_CONV_3D_REF()); |
492 | AddBuiltin(BuiltinOperator_IMAG, Register_IMAG()); |
493 | AddBuiltin(BuiltinOperator_REAL, Register_REAL()); |
494 | AddBuiltin(BuiltinOperator_COMPLEX_ABS, Register_COMPLEX_ABS()); |
495 | AddBuiltin(BuiltinOperator_CONV_3D_TRANSPOSE, |
496 | Register_CONV_3D_TRANSPOSE_REF()); |
497 | AddBuiltin(BuiltinOperator_BROADCAST_ARGS, Register_BROADCAST_ARGS()); |
498 | AddBuiltin(BuiltinOperator_MULTINOMIAL, Register_MULTINOMIAL()); |
499 | AddBuiltin(BuiltinOperator_RANDOM_STANDARD_NORMAL, |
500 | Register_RANDOM_STANDARD_NORMAL()); |
501 | AddBuiltin(BuiltinOperator_BUCKETIZE, Register_BUCKETIZE()); |
502 | AddBuiltin(BuiltinOperator_RANDOM_UNIFORM, Register_RANDOM_UNIFORM()); |
503 | AddBuiltin(BuiltinOperator_GELU, Register_GELU(), |
504 | /* min_version = */ 1, |
505 | /* max_version = */ 2); |
506 | AddBuiltin(BuiltinOperator_DYNAMIC_UPDATE_SLICE, |
507 | Register_DYNAMIC_UPDATE_SLICE()); |
508 | AddBuiltin(BuiltinOperator_UNSORTED_SEGMENT_PROD, |
509 | Register_UNSORTED_SEGMENT_PROD()); |
510 | AddBuiltin(BuiltinOperator_UNSORTED_SEGMENT_MAX, |
511 | Register_UNSORTED_SEGMENT_MAX()); |
512 | AddBuiltin(BuiltinOperator_UNSORTED_SEGMENT_MIN, |
513 | Register_UNSORTED_SEGMENT_MIN()); |
514 | AddBuiltin(BuiltinOperator_UNSORTED_SEGMENT_SUM, |
515 | Register_UNSORTED_SEGMENT_SUM()); |
516 | AddBuiltin(BuiltinOperator_ATAN2, Register_ATAN2()); |
517 | AddBuiltin(BuiltinOperator_SIGN, Register_SIGN()); |
518 | AddCustom("NumericVerify" , |
519 | tflite::ops::custom::Register_NUMERIC_VERIFY_REF()); |
520 | // TODO(andrewharp, ahentz): Move these somewhere more appropriate so that |
521 | // custom ops aren't always included by default. |
522 | AddCustom("Mfcc" , tflite::ops::custom::Register_MFCC()); |
523 | AddCustom("AudioSpectrogram" , |
524 | tflite::ops::custom::Register_AUDIO_SPECTROGRAM()); |
525 | AddCustom("TFLite_Detection_PostProcess" , |
526 | tflite::ops::custom::Register_DETECTION_POSTPROCESS()); |
527 | } |
528 | |
529 | } // namespace builtin |
530 | } // namespace ops |
531 | } // namespace tflite |
532 | |