MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / init_tensor

Method init_tensor

external/ggml/src/ggml-rpc/ggml-rpc.cpp:1148–1181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1146}
1147
1148bool rpc_server::init_tensor(const rpc_msg_init_tensor_req & request) {
1149 struct ggml_init_params params {
1150 /*.mem_size =*/ ggml_tensor_overhead(),
1151 /*.mem_buffer =*/ NULL,
1152 /*.no_alloc =*/ true,
1153 };
1154 ggml_context_ptr ctx_ptr { ggml_init(params) };
1155 GGML_ASSERT(ctx_ptr != nullptr);
1156 ggml_context * ctx = ctx_ptr.get();
1157 ggml_tensor * tensor = deserialize_tensor(ctx, &request.tensor);
1158 if (tensor == nullptr) {
1159 GGML_LOG_ERROR("Null tensor pointer passed to server init_tensor function.\n");
1160 return false;
1161 }
1162 LOG_DBG("[%s] buffer: %p, data: %p\n", __func__, (void*)tensor->buffer, tensor->data);
1163 // Call the backend's buffer_init_tensor function
1164 ggml_backend_buffer_t buffer = tensor->buffer;
1165 if (buffer && buffer->iface.init_tensor) {
1166 buffer->iface.init_tensor(buffer, tensor);
1167 } else {
1168 if (!buffer) {
1169 GGML_LOG_ERROR("Tensor with null buffer passed to init_tensor function\n");
1170 }
1171 }
1172
1173 if (tensor->extra != nullptr) {
1174 // This pointer can either be passed around client/server, or probably better stored server-side and kept track of.
1175 // Currently unimplemented.
1176 GGML_LOG_ERROR("tensor->extra populated by the backend, this is currently unsupported.\n");
1177 return false;
1178 }
1179
1180 return true;
1181}
1182
1183bool rpc_server::get_tensor(const rpc_msg_get_tensor_req & request, std::vector<uint8_t> & response) {
1184 struct ggml_init_params params {

Callers 2

rpc_serve_clientFunction · 0.80

Calls 3

ggml_tensor_overheadFunction · 0.85
ggml_initFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected