MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetRegistrationFromOpCode

Function GetRegistrationFromOpCode

tensorflow/lite/core/api/op_resolver.cc:20–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18namespace tflite {
19
20TfLiteStatus GetRegistrationFromOpCode(
21 const OperatorCode* opcode, const OpResolver& op_resolver,
22 ErrorReporter* error_reporter, const TfLiteRegistration** registration) {
23 TfLiteStatus status = kTfLiteOk;
24 *registration = nullptr;
25 auto builtin_code = opcode->builtin_code();
26 int version = opcode->version();
27
28 if (builtin_code > BuiltinOperator_MAX ||
29 builtin_code < BuiltinOperator_MIN) {
30 error_reporter->Report(
31 "Op builtin_code out of range: %d. Are you using old TFLite binary "
32 "with newer model?",
33 builtin_code);
34 status = kTfLiteError;
35 } else if (builtin_code != BuiltinOperator_CUSTOM) {
36 *registration = op_resolver.FindOp(builtin_code, version);
37 if (*registration == nullptr) {
38 error_reporter->Report(
39 "Didn't find op for builtin opcode '%s' version '%d'\n",
40 EnumNameBuiltinOperator(builtin_code), version);
41 status = kTfLiteError;
42 }
43 } else if (!opcode->custom_code()) {
44 error_reporter->Report(
45 "Operator with CUSTOM builtin_code has no custom_code.\n");
46 status = kTfLiteError;
47 } else {
48 const char* name = opcode->custom_code()->c_str();
49 *registration = op_resolver.FindOp(name, version);
50 if (*registration == nullptr) {
51 // Do not report error for unresolved custom op, we do the final check
52 // while preparing ops.
53 status = kTfLiteError;
54 }
55 }
56 return status;
57}
58
59} // namespace tflite

Callers 3

TESTFunction · 0.85
InvokeMethod · 0.85

Calls 5

EnumNameBuiltinOperatorFunction · 0.85
c_strMethod · 0.80
versionMethod · 0.45
ReportMethod · 0.45
FindOpMethod · 0.45

Tested by 1

TESTFunction · 0.68