Skip to content

Commit 9cba545

Browse files
committed
ggml: add new member in GGML's internal data structure
1 parent 5cf5e7d commit 9cba545

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ggml.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,7 @@ struct ggml_context {
22002200
bool mem_buffer_owned;
22012201
bool no_alloc;
22022202
bool no_alloc_save; // this is used to save the no_alloc state when using scratch buffers
2203+
bool use_hwaccel;
22032204

22042205
int n_objects;
22052206

@@ -2759,6 +2760,7 @@ struct ggml_context * ggml_init(struct ggml_init_params params) {
27592760
/*.mem_buffer_owned =*/ params.mem_buffer ? false : true,
27602761
/*.no_alloc =*/ params.no_alloc,
27612762
/*.no_alloc_save =*/ params.no_alloc,
2763+
/*.use_hwaccel =*/ params.use_hwaccel,
27622764
/*.n_objects =*/ 0,
27632765
/*.objects_begin =*/ NULL,
27642766
/*.objects_end =*/ NULL,
@@ -2990,9 +2992,13 @@ static struct ggml_tensor * ggml_new_tensor_impl(
29902992
/*.data =*/ obj_alloc_size > 0 ? (void *)(result + 1) : data,
29912993
/*.name =*/ { 0 },
29922994
/*.extra =*/ NULL,
2995+
/*.rank =*/ n_dims,
29932996
/*.padding =*/ { 0 },
29942997
};
29952998

2999+
if (ctx->use_hwaccel)
3000+
result->backend = GGML_BACKEND_TYPE_GPU;
3001+
29963002
// TODO: this should not be needed as long as we don't rely on aligned SIMD loads
29973003
//ggml_assert_aligned(result->data);
29983004

ggml.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,9 @@ extern "C" {
591591

592592
void * extra; // extra things e.g. for ggml-cuda.cu
593593

594-
char padding[8];
594+
int32_t rank;
595+
596+
char padding[20];
595597
};
596598

597599
static const size_t GGML_TENSOR_SIZE = sizeof(struct ggml_tensor);
@@ -657,6 +659,7 @@ extern "C" {
657659
size_t mem_size; // bytes
658660
void * mem_buffer; // if NULL, memory will be allocated internally
659661
bool no_alloc; // don't allocate memory for the tensor data
662+
bool use_hwaccel;
660663
};
661664

662665

0 commit comments

Comments
 (0)