From 0029cd64a4ab425ec00c498482eac0f06a8f3aa8 Mon Sep 17 00:00:00 2001 From: Matthew Sloyan Date: Mon, 28 Sep 2020 12:58:14 +0100 Subject: IVGCVSW-5282 Switch tests/TfLiteMobilenetQuantized-Armnn over to cxxopts * Required update to cxxopts v3.0 for unrecognised options to work. Signed-off-by: Matthew Sloyan Change-Id: If1803731474e42580d663c802a1f3ff240fadffe --- .../TfLiteMobilenetQuantized-Armnn.cpp | 39 ++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/TfLiteMobilenetQuantized-Armnn/TfLiteMobilenetQuantized-Armnn.cpp b/tests/TfLiteMobilenetQuantized-Armnn/TfLiteMobilenetQuantized-Armnn.cpp index b2d3f0f3f5..56b145d6ee 100644 --- a/tests/TfLiteMobilenetQuantized-Armnn/TfLiteMobilenetQuantized-Armnn.cpp +++ b/tests/TfLiteMobilenetQuantized-Armnn/TfLiteMobilenetQuantized-Armnn.cpp @@ -6,7 +6,7 @@ #include "../ImagePreprocessor.hpp" #include "armnnTfLiteParser/ITfLiteParser.hpp" -#include "boost/program_options.hpp" +#include #include using namespace armnnTfLiteParser; @@ -61,20 +61,33 @@ std::vector ParseDataset(const std::string& filename) std::string GetLabelsFilenameFromOptions(int argc, char* argv[]) { - namespace po = boost::program_options; - po::options_description desc("Validation Options"); - std::string fn(""); - desc.add_options() - ("labels", po::value(&fn), "Filename of a text file where in each line contains an image " - "filename and the correct label the network should predict when fed that image"); - po::variables_map vm; - po::parsed_options parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); - po::store(parsed, vm); - if (vm.count("labels")) + cxxopts::Options options("TfLiteMobilenetQuantized-Armnn","Validation Options"); + + std::string fileName; + try + { + options + .allow_unrecognised_options() + .add_options() + ("l,labels", + "Filename of a text file where in each line contains an image " + "filename and the correct label the network should predict when fed that image", + cxxopts::value(fileName)); + + auto result = options.parse(argc, argv); + } + catch (const cxxopts::OptionException& e) { - fn = vm["labels"].as(); + std::cerr << e.what() << std::endl; + exit(EXIT_FAILURE); } - return fn; + catch (const std::exception& e) + { + std::cerr << "Fatal internal error: [" << e.what() << "]" << std::endl; + exit(EXIT_FAILURE); + } + + return fileName; } -- cgit v1.2.1