MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / ParseDeviceString

Function ParseDeviceString

oneflow/core/framework/device.cpp:157–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155decltype(Placement4Device) Placement4Device = DECORATE(&RawPlacement4Device, ThreadLocal);
156
157Maybe<std::tuple<std::string, int, bool>> ParseDeviceString(std::string device_str) {
158 bool rematable = false;
159 if (device_str.size() > 6 && device_str.substr(device_str.size() - 6, 6) == "+remat") {
160 rematable = true;
161 device_str = device_str.substr(0, device_str.size() - 6);
162 }
163 std::string::size_type pos = device_str.find(':');
164 if (pos == std::string::npos) {
165 return std::make_tuple(device_str, -1, rematable);
166 } else {
167 std::string index_str = device_str.substr(pos + 1);
168 CHECK_OR_RETURN(IsStrInt(index_str))
169 << Error::InvalidValueError() << "Invalid device tag " << device_str;
170 return std::make_tuple(device_str.substr(0, pos), std::stoi(index_str), rematable);
171 }
172}
173
174} // namespace oneflow

Callers 3

ParseAndNewMethod · 0.85
CreateGeneratorFunction · 0.85

Calls 3

IsStrIntFunction · 0.85
findMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected