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

Function PmuStrToInt

ethos-u-corstone-1000/app/src/common/CliOptions.cpp:43–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42#if defined(ETHOS_U_NPU_ENABLED)
43int PmuStrToInt(const char* str, size_t maxVal, const std::string& errorPrefix)
44{
45 int value = 0;
46
47 try {
48 value = std::stoi(str);
49 } catch (const std::out_of_range&) {
50 throw std::runtime_error("Error: " + errorPrefix + " out of range value " + str);
51 } catch (const std::exception&) {
52 throw std::runtime_error("Error: " + errorPrefix + " non-numeric value " + str);
53 }
54
55 if (value < 0 || static_cast<size_t>(value) > maxVal) {
56 throw std::runtime_error("Error: " + errorPrefix + " " + str + " is out of range [0 - " +
57 std::to_string(maxVal) + "]");
58 }
59
60 return value;
61}
62
63bool ParsePmuArg(const char* counterIdxArg,
64 const char* eventIdArg,

Callers 1

ParsePmuArgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected