| 773 | } |
| 774 | |
| 775 | static std::vector<ggml_backend_dev_t> parse_device_list(const std::string & value) { |
| 776 | std::vector<ggml_backend_dev_t> devices; |
| 777 | auto dev_names = string_split<std::string>(value, ','); |
| 778 | if (dev_names.empty()) { |
| 779 | throw std::invalid_argument("no devices specified"); |
| 780 | } |
| 781 | if (dev_names.size() == 1 && dev_names[0] == "none") { |
| 782 | devices.push_back(nullptr); |
| 783 | } else { |
| 784 | for (const auto & device : dev_names) { |
| 785 | auto * dev = ggml_backend_dev_by_name(device.c_str()); |
| 786 | if (!dev || ggml_backend_dev_type(dev) == GGML_BACKEND_DEVICE_TYPE_CPU) { |
| 787 | throw std::invalid_argument(string_format("invalid device: %s", device.c_str())); |
| 788 | } |
| 789 | devices.push_back(dev); |
| 790 | } |
| 791 | devices.push_back(nullptr); |
| 792 | } |
| 793 | return devices; |
| 794 | } |
| 795 | |
| 796 | static void add_rpc_devices(const std::string & servers) { |
| 797 | auto rpc_servers = string_split<std::string>(servers, ','); |
no test coverage detected