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

Method ParseAndNew

oneflow/core/framework/device.cpp:84–96  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

82}
83
84/* static */ Maybe<Symbol<Device>> Device::ParseAndNew(const std::string& device_str) {
85 static thread_local HashMap<std::string, Symbol<Device>> map;
86 auto iter = map.find(device_str);
87 if (iter == map.end()) {
88 auto [type, device_id, rematable] = *JUST(ParseDeviceString(device_str));
89 CheckDeviceType(type);
90 if (device_id == -1) { device_id = GlobalProcessCtx::LocalRank(); }
91 Device device(type, device_id, rematable);
92 JUST(device.Init());
93 iter = map.emplace(device_str, SymbolOf(device)).first;
94 }
95 return iter->second;
96}
97
98std::string Device::ToRepr() const {
99 auto rematable_suffix = "";

Callers

nothing calls this directly

Calls 6

ParseDeviceStringFunction · 0.85
CheckDeviceTypeFunction · 0.85
SymbolOfFunction · 0.85
findMethod · 0.80
endMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected