9 #include <boost/program_options.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;
86 namespace po = boost::program_options;
88 po::options_description desc(
"Options");
92 (
"help,h",
"Display help messages")
94 "Input file containing float 32 ArmNN Input Graph")
96 "Quantization scheme," 97 " \"QAsymmU8\" or \"QAsymmS8\" or \"QSymm16\"," 98 " default value QAsymmU8")
99 (
"csvfile,c", po::value<std::string>(&
m_CsvFileName)->default_value(
""),
100 "CSV file containing paths for RAW input tensors")
102 "Preserve the input and output data types")
104 "Directory that output file will be written to")
105 (
"outfile,o", po::value<std::string>(&
m_OutputFileName)->required(),
"ArmNN output file name");
107 catch (
const std::exception& e)
109 std::cerr <<
"Fatal internal error: [" << e.what() <<
"]" << std::endl;
113 po::variables_map vm;
117 po::store(po::parse_command_line(argc, argv, desc), vm);
119 if (vm.count(
"help") || argc <= 1)
121 std::cout <<
"Convert a Fp32 ArmNN model to a quantized ArmNN model." << std::endl;
122 std::cout << std::endl;
123 std::cout << desc << std::endl;
129 catch (
const po::error& e)
131 std::cerr << e.what() << std::endl << std::endl;
132 std::cerr << desc << std::endl;
170 if (fs::exists(output))
172 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