| 1136 | } |
| 1137 | |
| 1138 | static std::vector<ggml_backend_dev_t> parse_device_list(const std::string & value) { |
| 1139 | std::vector<ggml_backend_dev_t> devices; |
| 1140 | auto dev_names = string_split<std::string>(value, ','); |
| 1141 | if (dev_names.empty()) { |
| 1142 | throw std::invalid_argument("no devices specified"); |
| 1143 | } |
| 1144 | if (dev_names.size() == 1 && dev_names[0] == "none") { |
| 1145 | devices.push_back(nullptr); |
| 1146 | } else { |
| 1147 | for (const auto & device : dev_names) { |
| 1148 | auto * dev = ggml_backend_dev_by_name(device.c_str()); |
| 1149 | if (!dev || ggml_backend_dev_type(dev) != GGML_BACKEND_DEVICE_TYPE_GPU) { |
| 1150 | throw std::invalid_argument(string_format("invalid device: %s", device.c_str())); |
| 1151 | } |
| 1152 | devices.push_back(dev); |
| 1153 | } |
| 1154 | devices.push_back(nullptr); |
| 1155 | } |
| 1156 | return devices; |
| 1157 | } |
| 1158 | |
| 1159 | static void add_rpc_devices(std::string servers) { |
| 1160 | auto rpc_servers = string_split<std::string>(servers, ','); |
no test coverage detected