MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / parse_device_list

Function parse_device_list

subprojects/llama.cpp/common/arg.cpp:775–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

773}
774
775static 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
796static void add_rpc_devices(const std::string & servers) {
797 auto rpc_servers = string_split<std::string>(servers, ',');

Callers 1

Calls 6

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

Tested by

no test coverage detected