blob: 9de03fb327847e869d59d4f7d979dc9fcfe6772d [file] [log] [blame]
Jim Flynn3091b062019-02-15 14:45:04 +00001//
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 Drozd59e15b02019-04-25 15:45:20 +01009#include <vector>
10#include "QuantizationDataSet.hpp"
Jim Flynn3091b062019-02-15 14:45:04 +000011
12namespace 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 Armagan2b03d642019-04-12 15:17:02 +010017// * the csv file -c <optional> detailing the paths for RAW input tensors to use for refinement
Jim Flynn3091b062019-02-15 14:45:04 +000018// * 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.
25class CommandLineProcessor
26{
27public:
28 bool ProcessCommandLine(int argc, char* argv[]);
29
30 std::string GetInputFileName() {return m_InputFileName;}
Sadik Armagan2b03d642019-04-12 15:17:02 +010031 std::string GetCsvFileName() {return m_CsvFileName;}
32 std::string GetCsvFileDirectory() {return m_CsvFileDirectory;}
Jim Flynn3091b062019-02-15 14:45:04 +000033 std::string GetOutputDirectoryName() {return m_OutputDirectory;}
34 std::string GetOutputFileName() {return m_OutputFileName;}
Sadik Armagandc2f7f42019-04-26 17:11:47 +010035 std::string GetQuantizationScheme() {return m_QuantizationScheme;}
Nina Drozd59e15b02019-04-25 15:45:20 +010036 QuantizationDataSet GetQuantizationDataSet() {return m_QuantizationDataSet;}
Éanna Ó Catháin5696bff2019-05-10 13:29:13 +010037 bool HasPreservedDataType() {return m_PreserveDataType;}
Nina Drozd59e15b02019-04-25 15:45:20 +010038 bool HasQuantizationData() {return !m_QuantizationDataSet.IsEmpty();}
39
40protected:
Jim Flynn3091b062019-02-15 14:45:04 +000041 std::string m_InputFileName;
Sadik Armagan2b03d642019-04-12 15:17:02 +010042 std::string m_CsvFileName;
43 std::string m_CsvFileDirectory;
Jim Flynn3091b062019-02-15 14:45:04 +000044 std::string m_OutputDirectory;
45 std::string m_OutputFileName;
Sadik Armagandc2f7f42019-04-26 17:11:47 +010046 std::string m_QuantizationScheme;
Nina Drozd59e15b02019-04-25 15:45:20 +010047 QuantizationDataSet m_QuantizationDataSet;
Éanna Ó Catháin5696bff2019-05-10 13:29:13 +010048 bool m_PreserveDataType;
Jim Flynn3091b062019-02-15 14:45:04 +000049};
50
51} // namespace armnnQuantizer
52