From 777871703d0a920716f03210554b4e53d88d4646 Mon Sep 17 00:00:00 2001 From: mike dupont Date: Sun, 26 Nov 2023 08:23:15 -0500 Subject: [PATCH] typeinfo\n\nnow printing out some type information (ugly) for each field, more work needed --- ggml.cpp | 26 ++++++++++++------------- print.hpp | 57 +++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 54 insertions(+), 29 deletions(-) diff --git a/ggml.cpp b/ggml.cpp index 80468993182f5..619545be52090 100644 --- a/ggml.cpp +++ b/ggml.cpp @@ -17987,19 +17987,19 @@ static_assert(GGUF_TYPE_COUNT == 13, "GGUF_TYPE_COUNT != 13"); void GGUF_TYPE_NAME_init(){ - GGUF_TYPE_NAME[GGUF_TYPE_UINT8] = "u8"; - GGUF_TYPE_NAME[GGUF_TYPE_INT8] = "i8"; - GGUF_TYPE_NAME[GGUF_TYPE_UINT16] = "u16"; - GGUF_TYPE_NAME[GGUF_TYPE_INT16] = "i16"; - GGUF_TYPE_NAME[GGUF_TYPE_UINT32] = "u32"; - GGUF_TYPE_NAME[GGUF_TYPE_INT32] = "i32"; - GGUF_TYPE_NAME[GGUF_TYPE_FLOAT32] = "f32"; - GGUF_TYPE_NAME[GGUF_TYPE_BOOL] = "bool"; - GGUF_TYPE_NAME[GGUF_TYPE_STRING] = "str"; - GGUF_TYPE_NAME[GGUF_TYPE_ARRAY] = "arr"; - GGUF_TYPE_NAME[GGUF_TYPE_UINT64] = "u64"; - GGUF_TYPE_NAME[GGUF_TYPE_INT64] = "i64"; - GGUF_TYPE_NAME[GGUF_TYPE_FLOAT64] = "f64"; + GGUF_TYPE_NAME[GGUF_TYPE_UINT8] = (char*)"u8"; + GGUF_TYPE_NAME[GGUF_TYPE_INT8] = (char*) "i8"; + GGUF_TYPE_NAME[GGUF_TYPE_UINT16] = (char*) "u16"; + GGUF_TYPE_NAME[GGUF_TYPE_INT16] = (char*) "i16"; + GGUF_TYPE_NAME[GGUF_TYPE_UINT32] = (char*) "u32"; + GGUF_TYPE_NAME[GGUF_TYPE_INT32] = (char*) "i32"; + GGUF_TYPE_NAME[GGUF_TYPE_FLOAT32] = (char*) "f32"; + GGUF_TYPE_NAME[GGUF_TYPE_BOOL] = (char*) "bool"; + GGUF_TYPE_NAME[GGUF_TYPE_STRING] = (char*) "str"; + GGUF_TYPE_NAME[GGUF_TYPE_ARRAY] = (char*) "arr"; + GGUF_TYPE_NAME[GGUF_TYPE_UINT64] = (char*) "u64"; + GGUF_TYPE_NAME[GGUF_TYPE_INT64] = (char*) "i64"; + GGUF_TYPE_NAME[GGUF_TYPE_FLOAT64] = (char*) "f64"; }; static_assert(GGUF_TYPE_COUNT == 13, "GGUF_TYPE_COUNT != 13"); diff --git a/print.hpp b/print.hpp index 2ab13c21b8103..41cdd5e268aaf 100644 --- a/print.hpp +++ b/print.hpp @@ -21,19 +21,28 @@ REFL_END REFL_TYPE(ggml_opt_context::ggml_grad ) REFL_END #endif + +REFL_TYPE(ggml_task_type ) +REFL_END +REFL_TYPE(ggml_type ) +REFL_END +REFL_TYPE(ggml_backend_type ) +REFL_END +//REFL_TYPE(long int * ) +//REFL_END REFL_TYPE(gpt_params ) -REFL_FIELD( seed ) -REFL_FIELD( n_threads) -REFL_FIELD( n_threads_batch) -REFL_FIELD( n_predict ) -REFL_FIELD( n_ctx ) -REFL_FIELD( n_batch) -REFL_FIELD( n_keep ) -REFL_FIELD( n_draft) -REFL_FIELD( n_chunks ) -REFL_FIELD( n_parallel) -REFL_FIELD( n_sequences) +//REFL_FIELD( seed ) +//REFL_FIELD( n_threads) +//REFL_FIELD( n_threads_batch) +//REFL_FIELD( n_predict ) +//REFL_FIELD( n_ctx ) +//REFL_FIELD( n_batch) +//REFL_FIELD( n_keep ) +//REFL_FIELD( n_draft) +//REFL_FIELD( n_chunks ) +//REFL_FIELD( n_parallel) +//REFL_FIELD( n_sequences) REFL_FIELD( p_accept ) REFL_FIELD( p_split ) REFL_FIELD( n_gpu_layers) @@ -586,6 +595,7 @@ REFL_END template constexpr auto get_value_type_name(const T t) noexcept { + return t.value_type; } @@ -635,7 +645,7 @@ namespace runtime2 using type_descriptor = type_descriptor; bool compact = depth == -1; // print type with members enclosed in braces - os << type_descriptor::name << " { "; + os << "Type2:" <::member; + //static_assert(trait::is_field_v); + + //os << get_value_type_name(member) << " = "; if constexpr (util::contains_instance(member.attributes)) { // use the debug attribute to print @@ -679,6 +693,9 @@ namespace runtime2 } else if constexpr (detail::is_ostream_printable_v) { // type supports printing natively, just use that + //constexpr auto vtype = refl::reflect(); + using type_descriptor = refl::descriptor::type_descriptor; + os << "Type:" << type_descriptor::name << ":"; os << value; @@ -719,26 +736,34 @@ namespace runtime2 void debug_impl(std::basic_ostream& os, const T& value, [[maybe_unused]] int depth) { using no_pointer_t = std::remove_pointer_t; + using type_descriptor = type_descriptor; if constexpr (std::is_same_v) { - os << (value ? "true" : "false"); + + os << "BOOL"<< (value ? "true" : "false"); } else if constexpr (std::is_pointer_v && !std::is_void_v && trait::is_reflectable_v) { if (value == nullptr) { - os << "nullptr"; + os << "POINTER:"<< "nullptr"; } else { + os << "Type0:" <) { + //os << "Type4:" < void print_fields(const T& t) { runtime2::debug(std::cout, t); - constexpr auto type = refl::reflect(); + //constexpr auto type = refl::reflect(); // constexpr auto membertype = refl::member_list();