| 155 | decltype(Placement4Device) Placement4Device = DECORATE(&RawPlacement4Device, ThreadLocal); |
| 156 | |
| 157 | Maybe<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 |
no test coverage detected