MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / parse_device_list

Function parse_device_list

smallthinker/common/arg.cpp:1138–1157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1136}
1137
1138static 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
1159static void add_rpc_devices(std::string servers) {
1160 auto rpc_servers = string_split<std::string>(servers, ',');

Callers 1

Calls 7

ggml_backend_dev_by_nameFunction · 0.85
string_formatFunction · 0.70
ggml_backend_dev_typeFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected