Jim Flynn | 3091b06 | 2019-02-15 14:45:04 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #pragma once |
| 6 | |
| 7 | #include <string> |
| 8 | #include <iostream> |
Nina Drozd | 59e15b0 | 2019-04-25 15:45:20 +0100 | [diff] [blame] | 9 | #include <vector> |
| 10 | #include "QuantizationDataSet.hpp" |
Jim Flynn | 3091b06 | 2019-02-15 14:45:04 +0000 | [diff] [blame] | 11 | |
| 12 | namespace armnnQuantizer |
| 13 | { |
| 14 | |
| 15 | // parses the command line to extract |
| 16 | // * the input file -f containing the serialized fp32 ArmNN input graph (must exist...and be a input graph file) |
Sadik Armagan | 2b03d64 | 2019-04-12 15:17:02 +0100 | [diff] [blame] | 17 | // * the csv file -c <optional> detailing the paths for RAW input tensors to use for refinement |
Jim Flynn | 3091b06 | 2019-02-15 14:45:04 +0000 | [diff] [blame] | 18 | // * the directory -d to place the output file into (must already exist and be writable) |
| 19 | // * the name of the file -o the quantized ArmNN input graph will be written to (must not already exist) |
| 20 | // * LATER: the min and max overrides to be applied to the inputs |
| 21 | // specified as -i <int> (input id) -n <float> (minimum) -x <float> (maximum) |
| 22 | // multiple sets of -i, -n, -x can appear on the command line but they must match |
| 23 | // in number i.e. a -n and -x for each -i and the id of the input must correspond |
| 24 | // to an input layer in the fp32 graph when it is loaded. |
| 25 | class CommandLineProcessor |
| 26 | { |
| 27 | public: |
| 28 | bool ProcessCommandLine(int argc, char* argv[]); |
| 29 | |
| 30 | std::string GetInputFileName() {return m_InputFileName;} |
Sadik Armagan | 2b03d64 | 2019-04-12 15:17:02 +0100 | [diff] [blame] | 31 | std::string GetCsvFileName() {return m_CsvFileName;} |
| 32 | std::string GetCsvFileDirectory() {return m_CsvFileDirectory;} |
Jim Flynn | 3091b06 | 2019-02-15 14:45:04 +0000 | [diff] [blame] | 33 | std::string GetOutputDirectoryName() {return m_OutputDirectory;} |
| 34 | std::string GetOutputFileName() {return m_OutputFileName;} |
Sadik Armagan | dc2f7f4 | 2019-04-26 17:11:47 +0100 | [diff] [blame] | 35 | std::string GetQuantizationScheme() {return m_QuantizationScheme;} |
Nina Drozd | 59e15b0 | 2019-04-25 15:45:20 +0100 | [diff] [blame] | 36 | QuantizationDataSet GetQuantizationDataSet() {return m_QuantizationDataSet;} |
Éanna Ó Catháin | 5696bff | 2019-05-10 13:29:13 +0100 | [diff] [blame] | 37 | bool HasPreservedDataType() {return m_PreserveDataType;} |
Nina Drozd | 59e15b0 | 2019-04-25 15:45:20 +0100 | [diff] [blame] | 38 | bool HasQuantizationData() {return !m_QuantizationDataSet.IsEmpty();} |
| 39 | |
| 40 | protected: |
Jim Flynn | 3091b06 | 2019-02-15 14:45:04 +0000 | [diff] [blame] | 41 | std::string m_InputFileName; |
Sadik Armagan | 2b03d64 | 2019-04-12 15:17:02 +0100 | [diff] [blame] | 42 | std::string m_CsvFileName; |
| 43 | std::string m_CsvFileDirectory; |
Jim Flynn | 3091b06 | 2019-02-15 14:45:04 +0000 | [diff] [blame] | 44 | std::string m_OutputDirectory; |
| 45 | std::string m_OutputFileName; |
Sadik Armagan | dc2f7f4 | 2019-04-26 17:11:47 +0100 | [diff] [blame] | 46 | std::string m_QuantizationScheme; |
Nina Drozd | 59e15b0 | 2019-04-25 15:45:20 +0100 | [diff] [blame] | 47 | QuantizationDataSet m_QuantizationDataSet; |
Éanna Ó Catháin | 5696bff | 2019-05-10 13:29:13 +0100 | [diff] [blame] | 48 | bool m_PreserveDataType; |
Jim Flynn | 3091b06 | 2019-02-15 14:45:04 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | } // namespace armnnQuantizer |
| 52 | |