8 #define BOOST_FILESYSTEM_NO_DEPRECATED 10 #include <boost/program_options.hpp> 11 #include <boost/filesystem/operations.hpp> 12 #include <boost/filesystem/path.hpp> 21 std::cerr <<
"No output directory specified" << std::endl;
25 if (dir[dir.length() - 1] !=
'/')
30 if (!boost::filesystem::exists(dir))
32 std::cerr <<
"Output directory [" << dir <<
"] does not exist" << std::endl;
36 if (!boost::filesystem::is_directory(dir))
38 std::cerr <<
"Given output directory [" << dir <<
"] is not a directory" << std::endl;
47 if (!boost::filesystem::exists(inputFileName))
49 std::cerr <<
"Provided file [" << inputFileName <<
"] does not exist" << std::endl;
53 if (boost::filesystem::is_directory(inputFileName))
55 std::cerr <<
"Given file [" << inputFileName <<
"] is a directory" << std::endl;
66 std::cerr <<
"No Quantization Scheme specified" << std::endl;
70 std::vector<std::string> supportedSchemes =
77 auto iterator = std::find(supportedSchemes.begin(), supportedSchemes.end(), scheme);
78 if (iterator == supportedSchemes.end())
80 std::cerr <<
"Quantization Scheme [" << scheme <<
"] is not supported" << std::endl;
89 namespace po = boost::program_options;
91 po::options_description desc(
"Options");
95 (
"help,h",
"Display help messages")
97 "Input file containing float 32 ArmNN Input Graph")
99 "Quantization scheme," 100 " \"QAsymmU8\" or \"QAsymmS8\" or \"QSymm16\"," 101 " default value QAsymmU8")
102 (
"csvfile,c", po::value<std::string>(&
m_CsvFileName)->default_value(
""),
103 "CSV file containing paths for RAW input tensors")
105 "Preserve the input and output data types")
107 "Directory that output file will be written to")
108 (
"outfile,o", po::value<std::string>(&
m_OutputFileName)->required(),
"ArmNN output file name");
110 catch (
const std::exception& e)
112 std::cerr <<
"Fatal internal error: [" << e.what() <<
"]" << std::endl;
116 po::variables_map vm;
120 po::store(po::parse_command_line(argc, argv, desc), vm);
122 if (vm.count(
"help") || argc <= 1)
124 std::cout <<
"Convert a Fp32 ArmNN model to a quantized ArmNN model." << std::endl;
125 std::cout << std::endl;
126 std::cout << desc << std::endl;
132 catch (
const po::error& e)
134 std::cerr << e.what() << std::endl << std::endl;
135 std::cerr << desc << std::endl;
173 if (boost::filesystem::exists(output))
175 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