File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -2200,6 +2200,7 @@ struct ggml_context {
2200
2200
bool mem_buffer_owned;
2201
2201
bool no_alloc;
2202
2202
bool no_alloc_save; // this is used to save the no_alloc state when using scratch buffers
2203
+ bool use_hwaccel;
2203
2204
2204
2205
int n_objects;
2205
2206
@@ -2759,6 +2760,7 @@ struct ggml_context * ggml_init(struct ggml_init_params params) {
2759
2760
/*.mem_buffer_owned =*/ params.mem_buffer ? false : true,
2760
2761
/*.no_alloc =*/ params.no_alloc,
2761
2762
/*.no_alloc_save =*/ params.no_alloc,
2763
+ /*.use_hwaccel =*/ params.use_hwaccel,
2762
2764
/*.n_objects =*/ 0,
2763
2765
/*.objects_begin =*/ NULL,
2764
2766
/*.objects_end =*/ NULL,
@@ -2990,9 +2992,13 @@ static struct ggml_tensor * ggml_new_tensor_impl(
2990
2992
/*.data =*/ obj_alloc_size > 0 ? (void *)(result + 1) : data,
2991
2993
/*.name =*/ { 0 },
2992
2994
/*.extra =*/ NULL,
2995
+ /*.rank =*/ n_dims,
2993
2996
/*.padding =*/ { 0 },
2994
2997
};
2995
2998
2999
+ if (ctx->use_hwaccel)
3000
+ result->backend = GGML_BACKEND_TYPE_GPU;
3001
+
2996
3002
// TODO: this should not be needed as long as we don't rely on aligned SIMD loads
2997
3003
//ggml_assert_aligned(result->data);
2998
3004
Original file line number Diff line number Diff line change @@ -591,7 +591,9 @@ extern "C" {
591
591
592
592
void * extra ; // extra things e.g. for ggml-cuda.cu
593
593
594
- char padding [8 ];
594
+ int32_t rank ;
595
+
596
+ char padding [20 ];
595
597
};
596
598
597
599
static const size_t GGML_TENSOR_SIZE = sizeof (struct ggml_tensor );
@@ -657,6 +659,7 @@ extern "C" {
657
659
size_t mem_size ; // bytes
658
660
void * mem_buffer ; // if NULL, memory will be allocated internally
659
661
bool no_alloc ; // don't allocate memory for the tensor data
662
+ bool use_hwaccel ;
660
663
};
661
664
662
665
You can’t perform that action at this time.
0 commit comments