| 645 | } |
| 646 | |
| 647 | std::unique_ptr<ArmNNExecutor::IParser> ArmNNExecutor::CreateParser() |
| 648 | { |
| 649 | const fs::path modelFilename = m_Params.m_ModelPath; |
| 650 | const std::string modelExtension = modelFilename.extension(); |
| 651 | |
| 652 | m_Params.m_IsModelBinary = modelExtension != ".json"; |
| 653 | std::unique_ptr<IParser> parser = nullptr; |
| 654 | // Forward to implementation based on the parser type |
| 655 | if (modelExtension == ".armnn") |
| 656 | { |
| 657 | #if defined(ARMNN_SERIALIZER) |
| 658 | parser = std::make_unique<ArmNNDeserializer>(); |
| 659 | #else |
| 660 | LogAndThrow("Not built with serialization support."); |
| 661 | #endif |
| 662 | } |
| 663 | else if (modelExtension == ".tflite") |
| 664 | { |
| 665 | #if defined(ARMNN_TF_LITE_PARSER) |
| 666 | parser = std::make_unique<TfliteParser>(m_Params); |
| 667 | #else |
| 668 | LogAndThrow("Not built with Tensorflow-Lite parser support."); |
| 669 | #endif |
| 670 | } |
| 671 | else if (modelExtension == ".onnx") |
| 672 | { |
| 673 | #if defined(ARMNN_ONNX_PARSER) |
| 674 | parser = std::make_unique<OnnxParser>(); |
| 675 | #else |
| 676 | LogAndThrow("Not built with Onnx parser support."); |
| 677 | #endif |
| 678 | } |
| 679 | if (parser == nullptr) |
| 680 | { |
| 681 | throw InvalidArgumentException("Unable to determine the model type based on the file name extension."); |
| 682 | } |
| 683 | return parser; |
| 684 | } |
| 685 | |
| 686 | void ArmNNExecutor::PrintOutputTensors(const armnn::OutputTensors* outputTensors, |
| 687 | unsigned int iteration) |
nothing calls this directly
no test coverage detected