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

Function ggml_backend_tensor_set_2d_async

external/ggml/src/ggml-backend.cpp:282–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280 backend->iface.get_tensor_async(backend, tensor, data, offset, size);
281 }
282}
283
284void ggml_backend_tensor_set_2d_async(ggml_backend_t backend, struct ggml_tensor * tensor, const void * data, size_t offset, size_t size,
285 size_t n_copies, size_t stride_tensor, size_t stride_data) {
286 GGML_ASSERT(backend);
287 GGML_ASSERT(tensor);
288 GGML_ASSERT(tensor->data != NULL && "tensor not allocated");
289
290 if (n_copies <= 1 || backend->iface.set_tensor_2d_async == NULL) {
291 for (size_t i = 0; i < n_copies; i++) {
292 ggml_backend_tensor_set_async(backend, tensor, (const char *) data + i*stride_data, offset + i*stride_tensor, size);
293 }
294 return;
295 }
296 if (size == 0) {
297 return;
298 }
299
300 GGML_ASSERT(tensor->data != NULL && "tensor not allocated");
301 GGML_ASSERT(offset + (n_copies-1)*stride_tensor + size <= ggml_nbytes(tensor) && "tensor write out of bounds");
302 backend->iface.set_tensor_2d_async(backend, tensor, data, offset, size, n_copies, stride_tensor, stride_data);
303}
304

Callers 1

Calls 2

ggml_nbytesFunction · 0.85

Tested by

no test coverage detected