From cad465253d743a8f083ea39b979cf421ba0095fa Mon Sep 17 00:00:00 2001 From: slaren Date: Wed, 24 Jan 2024 02:44:33 +0100 Subject: [PATCH] ggml : add tensor flags --- ggml.c | 1 + ggml.h | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ggml.c b/ggml.c index 534b68939..f1e25f09b 100644 --- a/ggml.c +++ b/ggml.c @@ -2548,6 +2548,7 @@ static struct ggml_tensor * ggml_new_tensor_impl( /*.nb =*/ { 0, 0, 0, 0 }, /*.op =*/ GGML_OP_NONE, /*.op_params =*/ { 0 }, + /*.flags =*/ 0, /*.is_param =*/ false, /*.grad =*/ NULL, /*.src =*/ { NULL }, diff --git a/ggml.h b/ggml.h index de8162b81..0025beddc 100644 --- a/ggml.h +++ b/ggml.h @@ -501,11 +501,17 @@ extern "C" { enum ggml_log_level { GGML_LOG_LEVEL_ERROR = 2, - GGML_LOG_LEVEL_WARN = 3, - GGML_LOG_LEVEL_INFO = 4, + GGML_LOG_LEVEL_WARN = 3, + GGML_LOG_LEVEL_INFO = 4, GGML_LOG_LEVEL_DEBUG = 5 }; + enum ggml_tensor_flags { + GGML_TENSOR_INPUT = 1, + GGML_TENSOR_OUTPUT = 2, + GGML_TENSOR_PARAM = 4, + }; + // ggml object struct ggml_object { size_t offs; @@ -539,7 +545,9 @@ extern "C" { // op params - allocated as int32_t for alignment int32_t op_params[GGML_MAX_OP_PARAMS / sizeof(int32_t)]; - bool is_param; + int32_t flags; + + bool is_param; // TODO: move to flags struct ggml_tensor * grad; struct ggml_tensor * src[GGML_MAX_SRC]; @@ -558,7 +566,7 @@ extern "C" { void * extra; // extra things e.g. for ggml-cuda.cu - char padding[8]; + char padding[12]; }; static const size_t GGML_TENSOR_SIZE = sizeof(struct ggml_tensor);