Skip to content

Commit

Permalink
ggml : tag ggml_tensor::backend as deprecated (llama/7290)
Browse files Browse the repository at this point in the history
  • Loading branch information
slaren authored and ggerganov committed May 28, 2024
1 parent dd9b64b commit 2077732
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/ggml/ggml.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ extern "C" {
// n-dimensional tensor
struct ggml_tensor {
enum ggml_type type;
enum ggml_backend_type backend;

GGML_DEPRECATED(enum ggml_backend_type backend, "use the buffer type to find the storage location of the tensor");

struct ggml_backend_buffer * buffer;

Expand Down
1 change: 0 additions & 1 deletion src/ggml-backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,6 @@ void ggml_backend_view_init(ggml_backend_buffer_t buffer, struct ggml_tensor * t

tensor->buffer = buffer;
tensor->data = (char *)tensor->view_src->data + tensor->view_offs;
tensor->backend = tensor->view_src->backend;
ggml_backend_buffer_init_tensor(buffer, tensor);
}

Expand Down
10 changes: 10 additions & 0 deletions src/ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -3178,6 +3178,12 @@ static struct ggml_tensor * ggml_new_tensor_impl(

struct ggml_tensor * const result = (struct ggml_tensor *)((char *)ctx->mem_buffer + obj_new->offs);

#ifdef __clang__
// temporary until ggml_tensor::backend is removed
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif

*result = (struct ggml_tensor) {
/*.type =*/ type,
/*.backend =*/ GGML_BACKEND_TYPE_CPU,
Expand All @@ -3200,6 +3206,10 @@ static struct ggml_tensor * ggml_new_tensor_impl(
/*.padding =*/ { 0 },
};

#ifdef __clang__
#pragma clang diagnostic pop
#endif

// TODO: this should not be needed as long as we don't rely on aligned SIMD loads
//ggml_assert_aligned(result->data);

Expand Down

0 comments on commit 2077732

Please sign in to comment.