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