ArmNN
 20.05
CommandLineProcessor Class Reference

#include <CommandLineProcessor.hpp>

Public Member Functions

bool ProcessCommandLine (int argc, char *argv[])
 
std::string GetInputFileName ()
 
std::string GetCsvFileName ()
 
std::string GetCsvFileDirectory ()
 
std::string GetOutputDirectoryName ()
 
std::string GetOutputFileName ()
 
std::string GetQuantizationScheme ()
 
QuantizationDataSet GetQuantizationDataSet ()
 
bool HasPreservedDataType ()
 
bool HasQuantizationData ()
 

Protected Attributes

std::string m_InputFileName
 
std::string m_CsvFileName
 
std::string m_CsvFileDirectory
 
std::string m_OutputDirectory
 
std::string m_OutputFileName
 
std::string m_QuantizationScheme
 
QuantizationDataSet m_QuantizationDataSet
 
bool m_PreserveDataType
 

Detailed Description

Definition at line 25 of file CommandLineProcessor.hpp.

Member Function Documentation

◆ GetCsvFileDirectory()

std::string GetCsvFileDirectory ( )
inline

◆ GetCsvFileName()

std::string GetCsvFileName ( )
inline

◆ GetInputFileName()

std::string GetInputFileName ( )
inline

Definition at line 30 of file CommandLineProcessor.hpp.

References CommandLineProcessor::m_InputFileName.

Referenced by main().

◆ GetOutputDirectoryName()

std::string GetOutputDirectoryName ( )
inline

Definition at line 33 of file CommandLineProcessor.hpp.

References CommandLineProcessor::m_OutputDirectory.

Referenced by main().

◆ GetOutputFileName()

std::string GetOutputFileName ( )
inline

Definition at line 34 of file CommandLineProcessor.hpp.

References CommandLineProcessor::m_OutputFileName.

Referenced by main().

◆ GetQuantizationDataSet()

QuantizationDataSet GetQuantizationDataSet ( )
inline

Definition at line 36 of file CommandLineProcessor.hpp.

References CommandLineProcessor::m_QuantizationDataSet.

Referenced by main().

◆ GetQuantizationScheme()

std::string GetQuantizationScheme ( )
inline

◆ HasPreservedDataType()

bool HasPreservedDataType ( )
inline

◆ HasQuantizationData()

bool HasQuantizationData ( )
inline

◆ ProcessCommandLine()

bool ProcessCommandLine ( int  argc,
char *  argv[] 
)

Definition at line 87 of file CommandLineProcessor.cpp.

References CommandLineProcessor::m_CsvFileDirectory, CommandLineProcessor::m_CsvFileName, CommandLineProcessor::m_InputFileName, CommandLineProcessor::m_OutputDirectory, CommandLineProcessor::m_OutputFileName, CommandLineProcessor::m_PreserveDataType, CommandLineProcessor::m_QuantizationDataSet, CommandLineProcessor::m_QuantizationScheme, armnnQuantizer::ValidateOutputDirectory(), armnnQuantizer::ValidateProvidedFile(), and armnnQuantizer::ValidateQuantizationScheme().

Referenced by main().

88 {
89  namespace po = boost::program_options;
90 
91  po::options_description desc("Options");
92  try
93  {
94  desc.add_options()
95  ("help,h", "Display help messages")
96  ("infile,f", po::value<std::string>(&m_InputFileName)->required(),
97  "Input file containing float 32 ArmNN Input Graph")
98  ("scheme,s", po::value<std::string>(&m_QuantizationScheme)->default_value("QAsymmU8"),
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")
104  ("preserve-data-type,p", po::bool_switch(&m_PreserveDataType)->default_value(false),
105  "Preserve the input and output data types")
106  ("outdir,d", po::value<std::string>(&m_OutputDirectory)->required(),
107  "Directory that output file will be written to")
108  ("outfile,o", po::value<std::string>(&m_OutputFileName)->required(), "ArmNN output file name");
109  }
110  catch (const std::exception& e)
111  {
112  std::cerr << "Fatal internal error: [" << e.what() << "]" << std::endl;
113  return false;
114  }
115 
116  po::variables_map vm;
117 
118  try
119  {
120  po::store(po::parse_command_line(argc, argv, desc), vm);
121 
122  if (vm.count("help") || argc <= 1)
123  {
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;
127  return false;
128  }
129 
130  po::notify(vm);
131  }
132  catch (const po::error& e)
133  {
134  std::cerr << e.what() << std::endl << std::endl;
135  std::cerr << desc << std::endl;
136  return false;
137  }
138 
140  {
141  return false;
142  }
143 
145  {
146  return false;
147  }
148 
149  if (m_CsvFileName != "")
150  {
152  {
153  return false;
154  }
155  else
156  {
157  boost::filesystem::path csvFilePath(m_CsvFileName);
158  m_CsvFileDirectory = csvFilePath.parent_path().c_str();
159  }
160 
161  // If CSV file is defined, create a QuantizationDataSet for specified CSV file.
162  m_QuantizationDataSet = QuantizationDataSet(m_CsvFileName);
163  }
164 
166  {
167  return false;
168  }
169 
170  std::string output(m_OutputDirectory);
171  output.append(m_OutputFileName);
172 
173  if (boost::filesystem::exists(output))
174  {
175  std::cerr << "Output file [" << output << "] already exists" << std::endl;
176  return false;
177  }
178 
179  return true;
180 }
bool ValidateQuantizationScheme(const std::string &scheme)
bool ValidateOutputDirectory(std::string &dir)
bool ValidateProvidedFile(const std::string &inputFileName)

Member Data Documentation

◆ m_CsvFileDirectory

std::string m_CsvFileDirectory
protected

◆ m_CsvFileName

std::string m_CsvFileName
protected

◆ m_InputFileName

std::string m_InputFileName
protected

◆ m_OutputDirectory

std::string m_OutputDirectory
protected

◆ m_OutputFileName

std::string m_OutputFileName
protected

◆ m_PreserveDataType

bool m_PreserveDataType
protected

◆ m_QuantizationDataSet

◆ m_QuantizationScheme

std::string m_QuantizationScheme
protected

The documentation for this class was generated from the following files: