• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include "ExecuteNetworkParams.hpp"
9 #include <armnn/IRuntime.hpp>
10 
11 /*
12  * Historically we use the ',' character to separate dimensions in a tensor shape. However, cxxopts will read this
13  * an an array of values which is fine until we have multiple tensors specified. This lumps the values of all shapes
14  * together in a single array and we cannot break it up again. We'll change the vector delimiter to a '.'. We do this
15  * as close as possible to the usage of cxxopts to avoid polluting other possible uses.
16  */
17 #define CXXOPTS_VECTOR_DELIMITER '.'
18 #include <cxxopts/cxxopts.hpp>
19 
20 /// Holds and parses program options for the ExecuteNetwork application
21 struct ProgramOptions
22 {
23     /// Initializes ProgramOptions by adding options to the underlying cxxopts::options object.
24     /// (Does not parse any options)
25     ProgramOptions();
26 
27     /// Runs ParseOptions() on initialization
28     ProgramOptions(int ac, const char* av[]);
29 
30     /// Parses program options from the command line or another source and stores
31     /// the values in member variables. It also checks the validity of the parsed parameters.
32     /// Throws a cxxopts exception if parsing fails or an armnn exception if parameters are not valid.
33     void ParseOptions(int ac, const char* av[]);
34 
35     /// Ensures that the parameters for ExecuteNetwork fit together
36     void ValidateExecuteNetworkParams();
37 
38     /// Ensures that the runtime options are valid
39     void ValidateRuntimeOptions();
40 
41     cxxopts::Options m_CxxOptions;
42     cxxopts::ParseResult m_CxxResult;
43 
44     ExecuteNetworkParams m_ExNetParams;
45     armnn::IRuntime::CreationOptions m_RuntimeOptions;
46 };