Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
op_resolver.cc
00001 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved. 00002 00003 Licensed under the Apache License, Version 2.0 (the "License"); 00004 you may not use this file except in compliance with the License. 00005 You may obtain a copy of the License at 00006 00007 http://www.apache.org/licenses/LICENSE-2.0 00008 00009 Unless required by applicable law or agreed to in writing, software 00010 distributed under the License is distributed on an "AS IS" BASIS, 00011 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 See the License for the specific language governing permissions and 00013 limitations under the License. 00014 ==============================================================================*/ 00015 00016 #include "tensorflow/lite/core/api/op_resolver.h" 00017 00018 namespace tflite { 00019 00020 TfLiteStatus GetRegistrationFromOpCode( 00021 const OperatorCode* opcode, const OpResolver& op_resolver, 00022 ErrorReporter* error_reporter, const TfLiteRegistration** registration) { 00023 TfLiteStatus status = kTfLiteOk; 00024 *registration = nullptr; 00025 auto builtin_code = opcode->builtin_code(); 00026 int version = opcode->version(); 00027 00028 if (builtin_code > BuiltinOperator_MAX || 00029 builtin_code < BuiltinOperator_MIN) { 00030 error_reporter->Report( 00031 "Op builtin_code out of range: %d. Are you using old TFLite binary " 00032 "with newer model?", 00033 builtin_code); 00034 status = kTfLiteError; 00035 } else if (builtin_code != BuiltinOperator_CUSTOM) { 00036 *registration = op_resolver.FindOp(builtin_code, version); 00037 if (*registration == nullptr) { 00038 error_reporter->Report( 00039 "Didn't find op for builtin opcode '%s' version '%d'\n", 00040 EnumNameBuiltinOperator(builtin_code), version); 00041 status = kTfLiteError; 00042 } 00043 } else if (!opcode->custom_code()) { 00044 error_reporter->Report( 00045 "Operator with CUSTOM builtin_code has no custom_code.\n"); 00046 status = kTfLiteError; 00047 } else { 00048 const char* name = opcode->custom_code()->c_str(); 00049 *registration = op_resolver.FindOp(name, version); 00050 if (*registration == nullptr) { 00051 // Do not report error for unresolved custom op, we do the final check 00052 // while preparing ops. 00053 status = kTfLiteError; 00054 } 00055 } 00056 return status; 00057 } 00058 00059 } // namespace tflite
Generated on Wed Jul 13 2022 16:03:35 by
