9 #include <cxxopts/cxxopts.hpp> 18 std::cerr <<
"No output directory specified" << std::endl;
22 if (dir[dir.length() - 1] !=
'/')
29 std::cerr <<
"Output directory [" << dir <<
"] does not exist" << std::endl;
33 if (!fs::is_directory(dir))
35 std::cerr <<
"Given output directory [" << dir <<
"] is not a directory" << std::endl;
44 if (!fs::exists(inputFileName))
46 std::cerr <<
"Provided file [" << inputFileName <<
"] does not exist" << std::endl;
50 if (fs::is_directory(inputFileName))
52 std::cerr <<
"Given file [" << inputFileName <<
"] is a directory" << std::endl;
63 std::cerr <<
"No Quantization Scheme specified" << std::endl;
67 std::vector<std::string> supportedSchemes =
74 auto iterator = std::find(supportedSchemes.begin(), supportedSchemes.end(), scheme);
75 if (iterator == supportedSchemes.end())
77 std::cerr <<
"Quantization Scheme [" << scheme <<
"] is not supported" << std::endl;
88 cxxopts::Options options(
"ArmnnQuantizer",
"Convert a Fp32 ArmNN model to a quantized ArmNN model.");
91 (
"h,help",
"Display help messages")
93 "Input file containing float 32 ArmNN Input Graph",
96 "Quantization scheme," 97 " \"QAsymmU8\" or \"QAsymmS8\" or \"QSymm16\"," 98 " default value QAsymmU8",
101 "CSV file containing paths for RAW input tensors",
102 cxxopts::value<std::string>(
m_CsvFileName)->default_value(
""))
103 (
"p,preserve-data-type",
104 "Preserve the input and output data types",
107 "Directory that output file will be written to",
110 "ArmNN output file name",
113 auto result = options.parse(argc, argv);
115 if (result.count(
"help") > 0 || argc <= 1)
117 std::cout << options.help() << std::endl;
122 std::string mandatorySingleParameters[] = {
"infile",
"outdir",
"outfile" };
123 for (
auto param : mandatorySingleParameters)
125 if (result.count(param) != 1)
127 std::cerr <<
"Parameter \'--" << param <<
"\' is required but missing." << std::endl;
132 catch (
const cxxopts::OptionException& e)
134 std::cerr << e.what() << std::endl << std::endl;
137 catch (
const std::exception& e)
139 std::cerr <<
"Fatal internal error: [" << e.what() <<
"]" << std::endl;
177 if (fs::exists(output))
179 std::cerr <<
"Output file [" << output <<
"] already exists" << std::endl;
bool ValidateQuantizationScheme(const std::string &scheme)
QuantizationDataSet is a structure which is created after parsing a quantization CSV file...
std::string m_CsvFileName
bool ProcessCommandLine(int argc, char *argv[])
QuantizationDataSet m_QuantizationDataSet
bool ValidateOutputDirectory(std::string &dir)
std::string m_OutputDirectory
std::string m_InputFileName
bool ValidateProvidedFile(const std::string &inputFileName)
std::string m_QuantizationScheme
std::string m_CsvFileDirectory
std::string m_OutputFileName