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 | [&] |
Matthew Bentham | 3e68b97 | 2019-04-09 13:10:46 +0100 | [diff] [blame] | 25 | (const InferenceTestOptions &commonOptions, |
| 26 | typename YoloInferenceModel::CommandLineOptions modelOptions) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 27 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 28 | if (!ValidateDirectory(modelOptions.m_ModelDir)) |
| 29 | { |
| 30 | return std::unique_ptr<YoloInferenceModel>(); |
| 31 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 32 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 33 | typename YoloInferenceModel::Params modelParams; |
| 34 | modelParams.m_ModelPath = modelOptions.m_ModelDir + "yolov1_tiny_voc2007_model.caffemodel"; |
Aron Virginas-Tar | 7cf0eaa | 2019-01-24 17:05:36 +0000 | [diff] [blame] | 35 | modelParams.m_InputBindings = { "data" }; |
| 36 | modelParams.m_OutputBindings = { "fc12" }; |
| 37 | modelParams.m_InputShapes = { inputTensorShape }; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 38 | modelParams.m_IsModelBinary = true; |
Aron Virginas-Tar | 339bcae | 2019-01-31 16:44:26 +0000 | [diff] [blame] | 39 | modelParams.m_ComputeDevices = modelOptions.GetComputeDevicesAsBackendIds(); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 40 | modelParams.m_VisualizePostOptimizationModel = modelOptions.m_VisualizePostOptimizationModel; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 41 | modelParams.m_EnableFp16TurboMode = modelOptions.m_EnableFp16TurboMode; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 42 | |
Matteo Martincigh | 00dda4a | 2019-08-14 11:42:30 +0100 | [diff] [blame] | 43 | return std::make_unique<YoloInferenceModel>(modelParams, |
| 44 | commonOptions.m_EnableProfiling, |
| 45 | commonOptions.m_DynamicBackendsPath); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 46 | }); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 47 | }); |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 48 | } |
| 49 | catch (const std::exception& e) |
| 50 | { |
| 51 | // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an |
| 52 | // exception of type std::length_error. |
| 53 | // Using stderr instead in this context as there is no point in nesting try-catch blocks here. |
| 54 | std::cerr << "WARNING: CaffeYolo-Armnn: An error has occurred when running " |
| 55 | "the classifier inference tests: " << e.what() << std::endl; |
| 56 | } |
| 57 | return retVal; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 58 | } |