ggml: add new member in GGML's internal data structure
This commit is contained in:
parent
5cf5e7d490
commit
9cba545fbf
2 changed files with 10 additions and 1 deletions
6
ggml.c
6
ggml.c
|
@ -2200,6 +2200,7 @@ struct ggml_context {
|
||||||
bool mem_buffer_owned;
|
bool mem_buffer_owned;
|
||||||
bool no_alloc;
|
bool no_alloc;
|
||||||
bool no_alloc_save; // this is used to save the no_alloc state when using scratch buffers
|
bool no_alloc_save; // this is used to save the no_alloc state when using scratch buffers
|
||||||
|
bool use_hwaccel;
|
||||||
|
|
||||||
int n_objects;
|
int n_objects;
|
||||||
|
|
||||||
|
@ -2759,6 +2760,7 @@ struct ggml_context * ggml_init(struct ggml_init_params params) {
|
||||||
/*.mem_buffer_owned =*/ params.mem_buffer ? false : true,
|
/*.mem_buffer_owned =*/ params.mem_buffer ? false : true,
|
||||||
/*.no_alloc =*/ params.no_alloc,
|
/*.no_alloc =*/ params.no_alloc,
|
||||||
/*.no_alloc_save =*/ params.no_alloc,
|
/*.no_alloc_save =*/ params.no_alloc,
|
||||||
|
/*.use_hwaccel =*/ params.use_hwaccel,
|
||||||
/*.n_objects =*/ 0,
|
/*.n_objects =*/ 0,
|
||||||
/*.objects_begin =*/ NULL,
|
/*.objects_begin =*/ NULL,
|
||||||
/*.objects_end =*/ NULL,
|
/*.objects_end =*/ NULL,
|
||||||
|
@ -2990,9 +2992,13 @@ static struct ggml_tensor * ggml_new_tensor_impl(
|
||||||
/*.data =*/ obj_alloc_size > 0 ? (void *)(result + 1) : data,
|
/*.data =*/ obj_alloc_size > 0 ? (void *)(result + 1) : data,
|
||||||
/*.name =*/ { 0 },
|
/*.name =*/ { 0 },
|
||||||
/*.extra =*/ NULL,
|
/*.extra =*/ NULL,
|
||||||
|
/*.rank =*/ n_dims,
|
||||||
/*.padding =*/ { 0 },
|
/*.padding =*/ { 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ctx->use_hwaccel)
|
||||||
|
result->backend = GGML_BACKEND_TYPE_GPU;
|
||||||
|
|
||||||
// TODO: this should not be needed as long as we don't rely on aligned SIMD loads
|
// TODO: this should not be needed as long as we don't rely on aligned SIMD loads
|
||||||
//ggml_assert_aligned(result->data);
|
//ggml_assert_aligned(result->data);
|
||||||
|
|
||||||
|
|
5
ggml.h
5
ggml.h
|
@ -591,7 +591,9 @@ extern "C" {
|
||||||
|
|
||||||
void * extra; // extra things e.g. for ggml-cuda.cu
|
void * extra; // extra things e.g. for ggml-cuda.cu
|
||||||
|
|
||||||
char padding[8];
|
int32_t rank;
|
||||||
|
|
||||||
|
char padding[20];
|
||||||
};
|
};
|
||||||
|
|
||||||
static const size_t GGML_TENSOR_SIZE = sizeof(struct ggml_tensor);
|
static const size_t GGML_TENSOR_SIZE = sizeof(struct ggml_tensor);
|
||||||
|
@ -657,6 +659,7 @@ extern "C" {
|
||||||
size_t mem_size; // bytes
|
size_t mem_size; // bytes
|
||||||
void * mem_buffer; // if NULL, memory will be allocated internally
|
void * mem_buffer; // if NULL, memory will be allocated internally
|
||||||
bool no_alloc; // don't allocate memory for the tensor data
|
bool no_alloc; // don't allocate memory for the tensor data
|
||||||
|
bool use_hwaccel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue