blob: d563faaab20e3d0d1c5092bc7eb07aded3c457d6 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5#include "../YoloInferenceTest.hpp"
6#include "armnnCaffeParser/ICaffeParser.hpp"
7#include "armnn/TypesUtils.hpp"
8
9int main(int argc, char* argv[])
10{
11 armnn::TensorShape inputTensorShape{ { 1, 3, YoloImageHeight, YoloImageWidth } };
12
13 using YoloInferenceModel = InferenceModel<armnnCaffeParser::ICaffeParser,
14 float>;
15
surmeh013537c2c2018-05-18 16:31:43 +010016 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 Bentham3e68b972019-04-09 13:10:46 +010025 (const InferenceTestOptions &commonOptions,
26 typename YoloInferenceModel::CommandLineOptions modelOptions)
telsoa014fcda012018-03-09 14:13:49 +000027 {
surmeh013537c2c2018-05-18 16:31:43 +010028 if (!ValidateDirectory(modelOptions.m_ModelDir))
29 {
30 return std::unique_ptr<YoloInferenceModel>();
31 }
telsoa014fcda012018-03-09 14:13:49 +000032
surmeh013537c2c2018-05-18 16:31:43 +010033 typename YoloInferenceModel::Params modelParams;
34 modelParams.m_ModelPath = modelOptions.m_ModelDir + "yolov1_tiny_voc2007_model.caffemodel";
Aron Virginas-Tar7cf0eaa2019-01-24 17:05:36 +000035 modelParams.m_InputBindings = { "data" };
36 modelParams.m_OutputBindings = { "fc12" };
37 modelParams.m_InputShapes = { inputTensorShape };
surmeh013537c2c2018-05-18 16:31:43 +010038 modelParams.m_IsModelBinary = true;
Aron Virginas-Tar339bcae2019-01-31 16:44:26 +000039 modelParams.m_ComputeDevices = modelOptions.GetComputeDevicesAsBackendIds();
surmeh013537c2c2018-05-18 16:31:43 +010040 modelParams.m_VisualizePostOptimizationModel = modelOptions.m_VisualizePostOptimizationModel;
telsoa01c577f2c2018-08-31 09:22:23 +010041 modelParams.m_EnableFp16TurboMode = modelOptions.m_EnableFp16TurboMode;
telsoa014fcda012018-03-09 14:13:49 +000042
Matteo Martincigh00dda4a2019-08-14 11:42:30 +010043 return std::make_unique<YoloInferenceModel>(modelParams,
44 commonOptions.m_EnableProfiling,
45 commonOptions.m_DynamicBackendsPath);
surmeh013537c2c2018-05-18 16:31:43 +010046 });
telsoa014fcda012018-03-09 14:13:49 +000047 });
surmeh013537c2c2018-05-18 16:31:43 +010048 }
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;
telsoa014fcda012018-03-09 14:13:49 +000058}