MCPcopy Create free account
hub / github.com/Arm-Examples/ML-examples / Validate

Method Validate

ethos-u-corstone-1000/app/src/common/RunnerOptions.cpp:58–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58bool RunnerOptions::Validate(const CliOptionsConfig& config) const
59{
60 if (this->modelPath.empty()) {
61 std::cerr << "Error: missing model path. Use "
62 << GetCliOptionName(CliOptionId::kModel) << "\n";
63 return false;
64 }
65
66 if (!std::filesystem::exists(this->modelPath)) {
67 std::cerr << "Error: model file does not exist: " << this->modelPath << "\n";
68 return false;
69 }
70
71 if (!SupportsOption(config, CliOptionId::kLabels) && !this->labelsPath.empty()) {
72 std::cerr << "Error: labels are not supported by this app\n";
73 return false;
74 }
75
76 if (!this->labelsPath.empty() && !std::filesystem::exists(this->labelsPath)) {
77 std::cerr << "Error: labels file does not exist: " << this->labelsPath << "\n";
78 return false;
79 }
80
81 if (this->inputMode == InputMode::kBinary &&
82 !SupportsOption(config, CliOptionId::kInputBin)) {
83 std::cerr << "Error: binary input is not supported by this app\n";
84 return false;
85 }
86
87 if (this->inputMode == InputMode::kImage &&
88 !SupportsOption(config, CliOptionId::kInputImage)) {
89 std::cerr << "Error: image input is not supported by this app\n";
90 return false;
91 }
92
93 if ((this->inputMode == InputMode::kUnset || this->inputs.empty()) &&
94 !config.allowMissingInput) {
95 const std::string acceptedInputs = AcceptedInputHelp(config);
96 std::cerr << "Error: missing input";
97 if (!acceptedInputs.empty()) {
98 std::cerr << ". Use " << acceptedInputs;
99 }
100 std::cerr << "\n";
101 return false;
102 }
103
104 for (const auto& input : this->inputs) {
105 if (!std::filesystem::exists(input)) {
106 std::cerr << "Error: input file does not exist: " << input << "\n";
107 return false;
108 }
109 }
110
111 if (this->useRandomInputIfMissing && this->inputs.empty() && this->outputs.size() > 1U) {
112 std::cerr << "Error: random input mode accepts at most one "
113 << GetCliOptionName(CliOptionId::kOutput) << " file\n";
114 return false;
115 }

Callers 1

RunCommandLineAppFunction · 0.80

Calls 3

GetCliOptionNameFunction · 0.85
SupportsOptionFunction · 0.85
AcceptedInputHelpFunction · 0.85

Tested by

no test coverage detected