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

Method New

oneflow/core/framework/device.cpp:61–74  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

59}
60
61/* static */ Maybe<Symbol<Device>> Device::New(const std::string& type, int64_t device_id,
62 bool rematable) {
63 CHECK_GE_OR_RETURN(device_id, 0)
64 << Error::InvalidValueError() << "Device ID should be non-negative";
65 static thread_local HashMap<std::tuple<std::string, int, bool>, Symbol<Device>> map;
66 auto key = std::make_tuple(type, device_id, rematable);
67 auto iter = map.find(key);
68 if (iter == map.end()) {
69 Device device(type, device_id, rematable);
70 JUST(device.Init());
71 iter = map.emplace(key, SymbolOf(device)).first;
72 }
73 return iter->second;
74}
75
76/* static */ Maybe<Symbol<Device>> Device::New(const std::string& type, int64_t device_id) {
77 return New(type, device_id, false);

Callers

nothing calls this directly

Calls 5

SymbolOfFunction · 0.85
findMethod · 0.80
NewFunction · 0.70
endMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected