ArmNN
 20.08
CaffeYolo-Armnn.cpp File Reference

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 9 of file CaffeYolo-Armnn.cpp.

References armnn::test::InferenceTestMain(), armnn::test::ValidateDirectory(), YoloImageHeight, and YoloImageWidth.

10 {
11  armnn::TensorShape inputTensorShape{ { 1, 3, YoloImageHeight, YoloImageWidth } };
12 
13  using YoloInferenceModel = InferenceModel<armnnCaffeParser::ICaffeParser,
14  float>;
15 
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  (const InferenceTestOptions &commonOptions,
26  typename YoloInferenceModel::CommandLineOptions modelOptions)
27  {
28  if (!ValidateDirectory(modelOptions.m_ModelDir))
29  {
30  return std::unique_ptr<YoloInferenceModel>();
31  }
32 
33  typename YoloInferenceModel::Params modelParams;
34  modelParams.m_ModelPath = modelOptions.m_ModelDir + "yolov1_tiny_voc2007_model.caffemodel";
35  modelParams.m_InputBindings = { "data" };
36  modelParams.m_OutputBindings = { "fc12" };
37  modelParams.m_InputShapes = { inputTensorShape };
38  modelParams.m_IsModelBinary = true;
39  modelParams.m_ComputeDevices = modelOptions.GetComputeDevicesAsBackendIds();
40  modelParams.m_VisualizePostOptimizationModel = modelOptions.m_VisualizePostOptimizationModel;
41  modelParams.m_EnableFp16TurboMode = modelOptions.m_EnableFp16TurboMode;
42 
43  return std::make_unique<YoloInferenceModel>(modelParams,
44  commonOptions.m_EnableProfiling,
45  commonOptions.m_DynamicBackendsPath);
46  });
47  });
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;
58 }
constexpr unsigned int YoloImageHeight
constexpr unsigned int YoloImageWidth
bool ValidateDirectory(std::string &dir)
int InferenceTestMain(int argc, char *argv[], const std::vector< unsigned int > &defaultTestCaseIds, TConstructTestCaseProvider constructTestCaseProvider)