aboutsummaryrefslogtreecommitdiff
path: root/src/armnnQuantizer
diff options
context:
space:
mode:
authorMatthew Sloyan <matthew.sloyan@arm.com>2020-10-08 16:41:47 +0100
committerMatthew Sloyan <matthew.sloyan@arm.com>2020-10-12 09:01:21 +0000
commit41ff7f8da0ac12012d1eef7be6d160f9e17c2aec (patch)
tree4dec545bc372bcd436af8c8f1ae791e3946ae70f /src/armnnQuantizer
parentcd2c5f5d944f7fba47dbf5108486932cf6b535c0 (diff)
downloadarmnn-41ff7f8da0ac12012d1eef7be6d160f9e17c2aec.tar.gz
IVGCVSW-5279 Switch armnnQuantizer over to cxxopts
Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com> Change-Id: I79f12ba33b3ca58cdc4be531ffbf72fa20690792
Diffstat (limited to 'src/armnnQuantizer')
-rw-r--r--src/armnnQuantizer/CommandLineProcessor.cpp85
1 files changed, 46 insertions, 39 deletions
diff --git a/src/armnnQuantizer/CommandLineProcessor.cpp b/src/armnnQuantizer/CommandLineProcessor.cpp
index ace4a506fb..74ad5e7dbc 100644
--- a/src/armnnQuantizer/CommandLineProcessor.cpp
+++ b/src/armnnQuantizer/CommandLineProcessor.cpp
@@ -6,7 +6,7 @@
#include "CommandLineProcessor.hpp"
#include <Filesystem.hpp>
-#include <boost/program_options.hpp>
+#include <cxxopts/cxxopts.hpp>
namespace armnnQuantizer
{
@@ -83,53 +83,60 @@ bool ValidateQuantizationScheme(const std::string& scheme)
bool CommandLineProcessor::ProcessCommandLine(int argc, char* argv[])
{
- namespace po = boost::program_options;
-
- po::options_description desc("Options");
try
{
- desc.add_options()
- ("help,h", "Display help messages")
- ("infile,f", po::value<std::string>(&m_InputFileName)->required(),
- "Input file containing float 32 ArmNN Input Graph")
- ("scheme,s", po::value<std::string>(&m_QuantizationScheme)->default_value("QAsymmU8"),
- "Quantization scheme,"
- " \"QAsymmU8\" or \"QAsymmS8\" or \"QSymm16\","
- " default value QAsymmU8")
- ("csvfile,c", po::value<std::string>(&m_CsvFileName)->default_value(""),
- "CSV file containing paths for RAW input tensors")
- ("preserve-data-type,p", po::bool_switch(&m_PreserveDataType)->default_value(false),
- "Preserve the input and output data types")
- ("outdir,d", po::value<std::string>(&m_OutputDirectory)->required(),
- "Directory that output file will be written to")
- ("outfile,o", po::value<std::string>(&m_OutputFileName)->required(), "ArmNN output file name");
- }
- catch (const std::exception& e)
- {
- std::cerr << "Fatal internal error: [" << e.what() << "]" << std::endl;
- return false;
- }
-
- po::variables_map vm;
-
- try
- {
- po::store(po::parse_command_line(argc, argv, desc), vm);
-
- if (vm.count("help") || argc <= 1)
+ cxxopts::Options options("ArmnnQuantizer","Convert a Fp32 ArmNN model to a quantized ArmNN model.");
+
+ options.add_options()
+ ("h,help", "Display help messages")
+ ("f,infile",
+ "Input file containing float 32 ArmNN Input Graph",
+ cxxopts::value<std::string>(m_InputFileName))
+ ("s,scheme",
+ "Quantization scheme,"
+ " \"QAsymmU8\" or \"QAsymmS8\" or \"QSymm16\","
+ " default value QAsymmU8",
+ cxxopts::value<std::string>(m_QuantizationScheme)->default_value("QAsymmU8"))
+ ("c,csvfile",
+ "CSV file containing paths for RAW input tensors",
+ cxxopts::value<std::string>(m_CsvFileName)->default_value(""))
+ ("p,preserve-data-type",
+ "Preserve the input and output data types",
+ cxxopts::value<bool>(m_PreserveDataType)->default_value("false"))
+ ("d,outdir",
+ "Directory that output file will be written to",
+ cxxopts::value<std::string>(m_OutputDirectory))
+ ("o,outfile",
+ "ArmNN output file name",
+ cxxopts::value<std::string>(m_OutputFileName));
+
+ auto result = options.parse(argc, argv);
+
+ if (result.count("help") > 0 || argc <= 1)
{
- std::cout << "Convert a Fp32 ArmNN model to a quantized ArmNN model." << std::endl;
- std::cout << std::endl;
- std::cout << desc << std::endl;
+ std::cout << options.help() << std::endl;
return false;
}
- po::notify(vm);
+ // Check for mandatory single options.
+ std::string mandatorySingleParameters[] = { "infile", "outdir", "outfile" };
+ for (auto param : mandatorySingleParameters)
+ {
+ if (result.count(param) != 1)
+ {
+ std::cerr << "Parameter \'--" << param << "\' is required but missing." << std::endl;
+ return false;
+ }
+ }
}
- catch (const po::error& e)
+ catch (const cxxopts::OptionException& e)
{
std::cerr << e.what() << std::endl << std::endl;
- std::cerr << desc << std::endl;
+ return false;
+ }
+ catch (const std::exception& e)
+ {
+ std::cerr << "Fatal internal error: [" << e.what() << "]" << std::endl;
return false;
}