static */
| 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 | |
| 98 | std::string Device::ToRepr() const { |
| 99 | auto rematable_suffix = ""; |
nothing calls this directly
no test coverage detected