Skip to content

Commit 344f912

Browse files
authored
ggml : tag ggml_tensor::backend as deprecated (#7290)
1 parent 9a17ab9 commit 344f912

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

examples/llava/llava.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ static struct clip_image_grid_shape get_anyres_image_grid_shape(const std::pair<
8888
// Take the image segments in a grid configuration and return the embeddings and the number of embeddings into preallocated memory (image_embd_out)
8989
static bool clip_llava_handle_patches(clip_ctx * ctx_clip, std::vector<float *> & image_embd_v, struct clip_image_grid_shape grid_shape, float * image_embd_out, int * n_img_pos_out) {
9090
struct {
91-
struct ggml_tensor * newline;
9291
struct ggml_context * ctx;
9392
} model;
9493

@@ -150,20 +149,6 @@ static bool clip_llava_handle_patches(clip_ctx * ctx_clip, std::vector<float *>
150149

151150
model.ctx = ggml_init(params);
152151

153-
ggml_tensor * newline_tmp = clip_get_newline_tensor(ctx_clip);
154-
model.newline = ggml_new_tensor_1d(model.ctx, GGML_TYPE_F32, newline_tmp->ne[0]);
155-
if (newline_tmp->backend != GGML_BACKEND_TYPE_CPU) {
156-
if (newline_tmp->buffer == NULL) {
157-
LOG_TEE("newline_tmp tensor buffer is NULL\n");
158-
}
159-
ggml_backend_tensor_get(newline_tmp, model.newline->data, 0, ggml_nbytes(newline_tmp));
160-
} else {
161-
model.newline->data = newline_tmp->data;
162-
if (model.newline->data == NULL) {
163-
LOG_TEE("newline_tmp tensor data is NULL\n");
164-
}
165-
}
166-
167152
struct ggml_tensor * image_features = ggml_new_tensor_3d(model.ctx, GGML_TYPE_F32, clip_n_mmproj_embd(ctx_clip), clip_n_patches(ctx_clip), num_images - 1); // example: 4096 x 576 x 4
168153
// ggml_tensor_printf(image_features,"image_features",__LINE__,false,false);
169154
// fill it with the image embeddings, ignoring the base

ggml-backend.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,6 @@ void ggml_backend_view_init(ggml_backend_buffer_t buffer, struct ggml_tensor * t
18951895

18961896
tensor->buffer = buffer;
18971897
tensor->data = (char *)tensor->view_src->data + tensor->view_offs;
1898-
tensor->backend = tensor->view_src->backend;
18991898
ggml_backend_buffer_init_tensor(buffer, tensor);
19001899
}
19011900

ggml.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3178,6 +3178,12 @@ static struct ggml_tensor * ggml_new_tensor_impl(
31783178

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

3181+
#ifdef __clang__
3182+
// temporary until ggml_tensor::backend is removed
3183+
#pragma clang diagnostic push
3184+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
3185+
#endif
3186+
31813187
*result = (struct ggml_tensor) {
31823188
/*.type =*/ type,
31833189
/*.backend =*/ GGML_BACKEND_TYPE_CPU,
@@ -3200,6 +3206,10 @@ static struct ggml_tensor * ggml_new_tensor_impl(
32003206
/*.padding =*/ { 0 },
32013207
};
32023208

3209+
#ifdef __clang__
3210+
#pragma clang diagnostic pop
3211+
#endif
3212+
32033213
// TODO: this should not be needed as long as we don't rely on aligned SIMD loads
32043214
//ggml_assert_aligned(result->data);
32053215

ggml.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ extern "C" {
565565
// n-dimensional tensor
566566
struct ggml_tensor {
567567
enum ggml_type type;
568-
enum ggml_backend_type backend;
568+
569+
GGML_DEPRECATED(enum ggml_backend_type backend, "use the buffer type to find the storage location of the tensor");
569570

570571
struct ggml_backend_buffer * buffer;
571572

0 commit comments

Comments
 (0)