telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #include "../YoloInferenceTest.hpp" |
| 6 | #include "armnnCaffeParser/ICaffeParser.hpp" |
| 7 | #include "armnn/TypesUtils.hpp" |
| 8 | |
| 9 | int main(int argc, char* argv[]) |
| 10 | { |
| 11 | armnn::TensorShape inputTensorShape{ { 1, 3, YoloImageHeight, YoloImageWidth } }; |
| 12 | |
| 13 | using YoloInferenceModel = InferenceModel<armnnCaffeParser::ICaffeParser, |
| 14 | float>; |
| 15 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 16 | int retVal = EXIT_FAILURE; |
| 17 | try |
| 18 | { |
| 19 | // Coverity fix: InferenceTestMain() may throw uncaught exceptions. |
| 20 | retVal = InferenceTestMain(argc, argv, { 0 }, |
| 21 | [&inputTensorShape]() |
| 22 | { |
| 23 | return make_unique<YoloTestCaseProvider<YoloInferenceModel>>( |
| 24 | [&] |
| 25 | (typename YoloInferenceModel::CommandLineOptions modelOptions) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 26 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 27 | if (!ValidateDirectory(modelOptions.m_ModelDir)) |
| 28 | { |
| 29 | return std::unique_ptr<YoloInferenceModel>(); |
| 30 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 31 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 32 | typename YoloInferenceModel::Params modelParams; |
| 33 | modelParams.m_ModelPath = modelOptions.m_ModelDir + "yolov1_tiny_voc2007_model.caffemodel"; |
| 34 | modelParams.m_InputBinding = "data"; |
| 35 | modelParams.m_OutputBinding = "fc12"; |
| 36 | modelParams.m_InputTensorShape = &inputTensorShape; |
| 37 | modelParams.m_IsModelBinary = true; |
| 38 | modelParams.m_ComputeDevice = modelOptions.m_ComputeDevice; |
| 39 | modelParams.m_VisualizePostOptimizationModel = modelOptions.m_VisualizePostOptimizationModel; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 40 | modelParams.m_EnableFp16TurboMode = modelOptions.m_EnableFp16TurboMode; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 41 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 42 | return std::make_unique<YoloInferenceModel>(modelParams); |
| 43 | }); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 44 | }); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 45 | } |
| 46 | catch (const std::exception& e) |
| 47 | { |
| 48 | // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an |
| 49 | // exception of type std::length_error. |
| 50 | // Using stderr instead in this context as there is no point in nesting try-catch blocks here. |
| 51 | std::cerr << "WARNING: CaffeYolo-Armnn: An error has occurred when running " |
| 52 | "the classifier inference tests: " << e.what() << std::endl; |
| 53 | } |
| 54 | return retVal; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 55 | } |