| 363 | } |
| 364 | |
| 365 | bool VerifyOps(const Model& model, const OpResolver& resolver, |
| 366 | ErrorReporter* error_reporter) { |
| 367 | if (!model.operator_codes()) { |
| 368 | return true; |
| 369 | } |
| 370 | for (const auto& opcode : *model.operator_codes()) { |
| 371 | if (opcode->builtin_code() < BuiltinOperator_MIN || |
| 372 | opcode->builtin_code() > BuiltinOperator_MAX) { |
| 373 | ReportError(error_reporter, "Operator id '%d' is out of range.", |
| 374 | opcode->builtin_code()); |
| 375 | return false; |
| 376 | } |
| 377 | |
| 378 | if (opcode->builtin_code() == BuiltinOperator_CUSTOM) { |
| 379 | if (!resolver.FindOp(opcode->custom_code()->c_str(), opcode->version())) { |
| 380 | ReportError(error_reporter, "Unsupported custom op: %s, version: %d", |
| 381 | opcode->custom_code()->c_str(), opcode->version()); |
| 382 | return false; |
| 383 | } |
| 384 | } else { |
| 385 | if (!resolver.FindOp(opcode->builtin_code(), opcode->version())) { |
| 386 | ReportError(error_reporter, "Unsupported builtin op: %s, version: %d", |
| 387 | EnumNameBuiltinOperator(opcode->builtin_code()), |
| 388 | opcode->version()); |
| 389 | return false; |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | return true; |
| 394 | } |
| 395 | |
| 396 | } // namespace |
| 397 |
no test coverage detected