MCPcopy Create free account
hub / github.com/ARM-software/armnn / ParseCommandLine

Function ParseCommandLine

tests/InferenceTest.cpp:28–82  ·  view source on GitHub ↗

Parse the command line of an ArmNN inference test program. \return false if any error occurred during options processing, otherwise true

Source from the content-addressed store, hash-verified

26/// Parse the command line of an ArmNN inference test program.
27/// \return false if any error occurred during options processing, otherwise true
28bool ParseCommandLine(int argc, char** argv, IInferenceTestCaseProvider& testCaseProvider,
29 InferenceTestOptions& outParams)
30{
31 cxxopts::Options options("InferenceTest", "Inference iteration parameters");
32
33 try
34 {
35 // Adds generic options needed for all inference tests.
36 options
37 .allow_unrecognised_options()
38 .add_options()
39 ("h,help", "Display help messages")
40 ("i,iterations", "Sets the number of inferences to perform. If unset, will only be run once.",
41 cxxopts::value<unsigned int>(outParams.m_IterationCount)->default_value("0"))
42 ("inference-times-file",
43 "If non-empty, each individual inference time will be recorded and output to this file",
44 cxxopts::value<std::string>(outParams.m_InferenceTimesFile)->default_value(""))
45 ("e,event-based-profiling", "Enables built in profiler. If unset, defaults to off.",
46 cxxopts::value<bool>(outParams.m_EnableProfiling)->default_value("0"));
47
48 std::vector<std::string> required; //to be passed as reference to derived inference tests
49
50 // Adds options specific to the ITestCaseProvider.
51 testCaseProvider.AddCommandLineOptions(options, required);
52
53 auto result = options.parse(argc, argv);
54
55 if (result.count("help"))
56 {
57 std::cout << options.help() << std::endl;
58 return false;
59 }
60
61 CheckRequiredOptions(result, required);
62
63 }
64 catch (const cxxopts::exceptions::exception& e)
65 {
66 std::cerr << e.what() << std::endl << options.help() << std::endl;
67 return false;
68 }
69 catch (const std::exception& e)
70 {
71 ARMNN_ASSERT_MSG(false, "Caught unexpected exception");
72 std::cerr << "Fatal internal error: " << e.what() << std::endl;
73 return false;
74 }
75
76 if (!testCaseProvider.ProcessCommandLineOptions(outParams))
77 {
78 return false;
79 }
80
81 return true;
82}
83
84bool ValidateDirectory(std::string& dir)
85{

Callers

nothing calls this directly

Calls 9

add_optionsMethod · 0.80
default_valueMethod · 0.80
helpMethod · 0.80
CheckRequiredOptionsFunction · 0.70
AddCommandLineOptionsMethod · 0.45
parseMethod · 0.45
countMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected