return &guid;
}
+struct ggml_backend_rpc_device_context {
+ std::string endpoint;
+ uint32_t device;
+ std::string name;
+ std::string description;
+ uint64_t last_graph_uid;
+};
+
struct ggml_backend_rpc_buffer_type_context {
std::string endpoint;
uint32_t device;
std::string endpoint;
uint32_t device;
std::string name;
- uint64_t last_graph_uid;
};
struct ggml_backend_rpc_buffer_context {
static enum ggml_status ggml_backend_rpc_graph_compute(ggml_backend_t backend, ggml_cgraph * cgraph) {
ggml_backend_rpc_context * rpc_ctx = (ggml_backend_rpc_context *)backend->context;
+ ggml_backend_dev_t rpc_dev = ggml_backend_get_device(backend);
+ ggml_backend_rpc_device_context * rpc_dev_ctx = (ggml_backend_rpc_device_context *)rpc_dev->context;
GGML_ASSERT(cgraph->n_nodes > 0);
- bool reuse = cgraph->uid != 0 && rpc_ctx->last_graph_uid == cgraph->uid;
+ bool reuse = cgraph->uid != 0 && rpc_dev_ctx->last_graph_uid == cgraph->uid;
if (reuse) {
rpc_msg_graph_recompute_req request;
request.device = rpc_ctx->device;
bool status = send_rpc_cmd(sock, RPC_CMD_GRAPH_RECOMPUTE, &request, sizeof(request));
RPC_STATUS_ASSERT(status);
} else {
- rpc_ctx->last_graph_uid = cgraph->uid;
+ rpc_dev_ctx->last_graph_uid = cgraph->uid;
std::vector<uint8_t> input;
serialize_graph(rpc_ctx->device, cgraph, input);
auto sock = get_socket(rpc_ctx->endpoint);
/* .endpoint = */ endpoint,
/* .device = */ device,
/* .name = */ dev_name,
- /* .last_graph_uid = */ 0,
};
auto reg = ggml_backend_rpc_add_server(endpoint);
ggml_backend_t backend = new ggml_backend {
}
}
-// device interface
-
-struct ggml_backend_rpc_device_context {
- std::string endpoint;
- uint32_t device;
- std::string name;
- std::string description;
-};
-
static const char * ggml_backend_rpc_device_get_name(ggml_backend_dev_t dev) {
ggml_backend_rpc_device_context * ctx = (ggml_backend_rpc_device_context *)dev->context;
std::string dev_name = "RPC" + std::to_string(dev_id);
std::string dev_desc = std::string(endpoint);
ggml_backend_rpc_device_context * dev_ctx = new ggml_backend_rpc_device_context {
- /* .endpoint = */ endpoint,
- /* .device = */ ind,
- /* .name = */ dev_name,
- /* .description = */ dev_desc
+ /* .endpoint = */ endpoint,
+ /* .device = */ ind,
+ /* .name = */ dev_name,
+ /* .description = */ dev_desc,
+ /* .last_graph_uid = */ 0,
};
ggml_backend_dev_t dev = new ggml_backend_device {