MCPcopy Create free account
hub / github.com/catboost/catboost / ParseMemorySizeDescription

Function ParseMemorySizeDescription

catboost/libs/helpers/memory_utils.cpp:42–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42ui64 ParseMemorySizeDescription(const TStringBuf description) {
43 char* suffixBegin = nullptr;
44 const double number = StrToD(description.begin(), description.end(), &suffixBegin);
45 if (suffixBegin > description.begin() && number >= 0) {
46 // `number` is valid
47 const auto suffix = to_lower(TString(suffixBegin, description.end()));
48 if (suffix == "tb") {
49 return static_cast<ui64>(number * (1ll << 40));
50 } else if (suffix == "gb") {
51 return static_cast<ui64>(number * (1ll << 30));
52 } else if (suffix == "mb") {
53 return static_cast<ui64>(number * (1ll << 20));
54 } else if (suffix == "kb") {
55 return static_cast<ui64>(number * (1ll << 10));
56 } else if (suffix == "b" || suffix.empty()) {
57 return static_cast<ui64>(number);
58 }
59 } else {
60 if (IsInfinity(ToLowerUTF8(description))) {
61 return Max<ui64>();
62 }
63 }
64 CB_ENSURE(false, "incomprehensible memory size description: " << description);
65}

Callers 15

TFinalCtrsCalcerMethod · 0.85
GridSearchFunction · 0.85
RandomizedSearchFunction · 0.85
ValidateMethod · 0.85
ShuffleLearnDataIfNeededFunction · 0.85
GetTrainingDataFunction · 0.85
TrainModelFunction · 0.85
ModelBasedEvalFunction · 0.85

Calls 7

StrToDFunction · 0.85
to_lowerFunction · 0.85
IsInfinityFunction · 0.85
ToLowerUTF8Function · 0.50
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected