minor
This commit is contained in:
parent
26e97b5861
commit
ab6ad5e6e8
1 changed files with 5 additions and 9 deletions
|
@ -330,6 +330,8 @@ size_t ggml_backend_reg_find_by_name(const char * name) {
|
|||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// not found
|
||||
return SIZE_MAX;
|
||||
}
|
||||
|
||||
|
@ -340,15 +342,15 @@ ggml_backend_t ggml_backend_reg_init_backend_from_str(const char * backend_str)
|
|||
const char * params = strchr(backend_str, ':');
|
||||
char backend_name[128];
|
||||
if (params == NULL) {
|
||||
strcpy(backend_name, backend_str);
|
||||
snprintf(backend_name, sizeof(backend_name), "%s", backend_str);
|
||||
params = "";
|
||||
} else {
|
||||
strncpy(backend_name, backend_str, params - backend_str);
|
||||
backend_name[params - backend_str] = '\0';
|
||||
snprintf(backend_name, sizeof(backend_name), "%.*s", (int)(params - backend_str), backend_str);
|
||||
params++;
|
||||
}
|
||||
|
||||
size_t backend_i = ggml_backend_reg_find_by_name(backend_name);
|
||||
|
||||
if (backend_i == SIZE_MAX) {
|
||||
fprintf(stderr, "%s: backend %s not found\n", __func__, backend_name);
|
||||
return NULL;
|
||||
|
@ -396,18 +398,12 @@ static void ggml_backend_cpu_buffer_free_buffer(ggml_backend_buffer_t buffer) {
|
|||
}
|
||||
|
||||
static void ggml_backend_cpu_buffer_set_tensor(ggml_backend_buffer_t buffer, struct ggml_tensor * tensor, const void * data, size_t offset, size_t size) {
|
||||
GGML_ASSERT(offset + size <= ggml_nbytes(tensor) && "tensor write out of bounds");
|
||||
GGML_ASSERT(tensor->data != NULL && "tensor not allocated");
|
||||
|
||||
memcpy((char *)tensor->data + offset, data, size);
|
||||
|
||||
GGML_UNUSED(buffer);
|
||||
}
|
||||
|
||||
static void ggml_backend_cpu_buffer_get_tensor(ggml_backend_buffer_t buffer, const struct ggml_tensor * tensor, void * data, size_t offset, size_t size) {
|
||||
GGML_ASSERT(offset + size <= ggml_nbytes(tensor) && "tensor read out of bounds");
|
||||
GGML_ASSERT(tensor->data != NULL && "tensor not allocated");
|
||||
|
||||
memcpy(data, (const char *)tensor->data + offset, size);
|
||||
|
||||
GGML_UNUSED(buffer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue