typeinfo\n\nnow printing out some type information (ugly) for each field, more work needed
This commit is contained in:
parent
ec2b03e504
commit
777871703d
2 changed files with 54 additions and 29 deletions
26
ggml.cpp
26
ggml.cpp
|
@ -17987,19 +17987,19 @@ static_assert(GGUF_TYPE_COUNT == 13, "GGUF_TYPE_COUNT != 13");
|
||||||
|
|
||||||
|
|
||||||
void GGUF_TYPE_NAME_init(){
|
void GGUF_TYPE_NAME_init(){
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_UINT8] = "u8";
|
GGUF_TYPE_NAME[GGUF_TYPE_UINT8] = (char*)"u8";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_INT8] = "i8";
|
GGUF_TYPE_NAME[GGUF_TYPE_INT8] = (char*) "i8";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_UINT16] = "u16";
|
GGUF_TYPE_NAME[GGUF_TYPE_UINT16] = (char*) "u16";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_INT16] = "i16";
|
GGUF_TYPE_NAME[GGUF_TYPE_INT16] = (char*) "i16";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_UINT32] = "u32";
|
GGUF_TYPE_NAME[GGUF_TYPE_UINT32] = (char*) "u32";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_INT32] = "i32";
|
GGUF_TYPE_NAME[GGUF_TYPE_INT32] = (char*) "i32";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_FLOAT32] = "f32";
|
GGUF_TYPE_NAME[GGUF_TYPE_FLOAT32] = (char*) "f32";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_BOOL] = "bool";
|
GGUF_TYPE_NAME[GGUF_TYPE_BOOL] = (char*) "bool";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_STRING] = "str";
|
GGUF_TYPE_NAME[GGUF_TYPE_STRING] = (char*) "str";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_ARRAY] = "arr";
|
GGUF_TYPE_NAME[GGUF_TYPE_ARRAY] = (char*) "arr";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_UINT64] = "u64";
|
GGUF_TYPE_NAME[GGUF_TYPE_UINT64] = (char*) "u64";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_INT64] = "i64";
|
GGUF_TYPE_NAME[GGUF_TYPE_INT64] = (char*) "i64";
|
||||||
GGUF_TYPE_NAME[GGUF_TYPE_FLOAT64] = "f64";
|
GGUF_TYPE_NAME[GGUF_TYPE_FLOAT64] = (char*) "f64";
|
||||||
};
|
};
|
||||||
static_assert(GGUF_TYPE_COUNT == 13, "GGUF_TYPE_COUNT != 13");
|
static_assert(GGUF_TYPE_COUNT == 13, "GGUF_TYPE_COUNT != 13");
|
||||||
|
|
||||||
|
|
57
print.hpp
57
print.hpp
|
@ -21,19 +21,28 @@ REFL_END
|
||||||
REFL_TYPE(ggml_opt_context::ggml_grad )
|
REFL_TYPE(ggml_opt_context::ggml_grad )
|
||||||
REFL_END
|
REFL_END
|
||||||
#endif
|
#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_TYPE(gpt_params )
|
||||||
|
|
||||||
REFL_FIELD( seed )
|
//REFL_FIELD( seed )
|
||||||
REFL_FIELD( n_threads)
|
//REFL_FIELD( n_threads)
|
||||||
REFL_FIELD( n_threads_batch)
|
//REFL_FIELD( n_threads_batch)
|
||||||
REFL_FIELD( n_predict )
|
//REFL_FIELD( n_predict )
|
||||||
REFL_FIELD( n_ctx )
|
//REFL_FIELD( n_ctx )
|
||||||
REFL_FIELD( n_batch)
|
//REFL_FIELD( n_batch)
|
||||||
REFL_FIELD( n_keep )
|
//REFL_FIELD( n_keep )
|
||||||
REFL_FIELD( n_draft)
|
//REFL_FIELD( n_draft)
|
||||||
REFL_FIELD( n_chunks )
|
//REFL_FIELD( n_chunks )
|
||||||
REFL_FIELD( n_parallel)
|
//REFL_FIELD( n_parallel)
|
||||||
REFL_FIELD( n_sequences)
|
//REFL_FIELD( n_sequences)
|
||||||
REFL_FIELD( p_accept )
|
REFL_FIELD( p_accept )
|
||||||
REFL_FIELD( p_split )
|
REFL_FIELD( p_split )
|
||||||
REFL_FIELD( n_gpu_layers)
|
REFL_FIELD( n_gpu_layers)
|
||||||
|
@ -586,6 +595,7 @@ REFL_END
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr auto get_value_type_name(const T t) noexcept
|
constexpr auto get_value_type_name(const T t) noexcept
|
||||||
{
|
{
|
||||||
|
|
||||||
return t.value_type;
|
return t.value_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,7 +645,7 @@ namespace runtime2
|
||||||
using type_descriptor = type_descriptor<T>;
|
using type_descriptor = type_descriptor<T>;
|
||||||
bool compact = depth == -1;
|
bool compact = depth == -1;
|
||||||
// print type with members enclosed in braces
|
// print type with members enclosed in braces
|
||||||
os << type_descriptor::name << " { ";
|
os << "Type2:" <<type_descriptor::name << " { ";
|
||||||
if (!compact) os << '\n';
|
if (!compact) os << '\n';
|
||||||
|
|
||||||
constexpr auto readable_members = filter(type_descriptor::members, [](auto member) { return is_readable(member); });
|
constexpr auto readable_members = filter(type_descriptor::members, [](auto member) { return is_readable(member); });
|
||||||
|
@ -643,7 +653,11 @@ namespace runtime2
|
||||||
int new_depth = next_depth(depth);
|
int new_depth = next_depth(depth);
|
||||||
|
|
||||||
indent(os, new_depth);
|
indent(os, new_depth);
|
||||||
os << get_display_name(member) << " = ";
|
os << get_display_name(member) << "/";
|
||||||
|
//using typename member_descriptor_base<T, 0>::member;
|
||||||
|
//static_assert(trait::is_field_v<member>);
|
||||||
|
|
||||||
|
//os << get_value_type_name(member) << " = ";
|
||||||
|
|
||||||
if constexpr (util::contains_instance<attr::debug>(member.attributes)) {
|
if constexpr (util::contains_instance<attr::debug>(member.attributes)) {
|
||||||
// use the debug attribute to print
|
// use the debug attribute to print
|
||||||
|
@ -679,6 +693,9 @@ namespace runtime2
|
||||||
}
|
}
|
||||||
else if constexpr (detail::is_ostream_printable_v<CharT, T>) {
|
else if constexpr (detail::is_ostream_printable_v<CharT, T>) {
|
||||||
// type supports printing natively, just use that
|
// type supports printing natively, just use that
|
||||||
|
//constexpr auto vtype = refl::reflect<T>();
|
||||||
|
using type_descriptor = refl::descriptor::type_descriptor<T>;
|
||||||
|
os << "Type:" << type_descriptor::name << ":";
|
||||||
|
|
||||||
os << value;
|
os << value;
|
||||||
|
|
||||||
|
@ -719,26 +736,34 @@ namespace runtime2
|
||||||
void debug_impl(std::basic_ostream<CharT>& os, const T& value, [[maybe_unused]] int depth)
|
void debug_impl(std::basic_ostream<CharT>& os, const T& value, [[maybe_unused]] int depth)
|
||||||
{
|
{
|
||||||
using no_pointer_t = std::remove_pointer_t<T>;
|
using no_pointer_t = std::remove_pointer_t<T>;
|
||||||
|
using type_descriptor = type_descriptor<T>;
|
||||||
|
|
||||||
if constexpr (std::is_same_v<bool, T>) {
|
if constexpr (std::is_same_v<bool, T>) {
|
||||||
os << (value ? "true" : "false");
|
|
||||||
|
os << "BOOL"<< (value ? "true" : "false");
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_pointer_v<T> && !std::is_void_v<no_pointer_t> && trait::is_reflectable_v<no_pointer_t>) {
|
else if constexpr (std::is_pointer_v<T> && !std::is_void_v<no_pointer_t> && trait::is_reflectable_v<no_pointer_t>) {
|
||||||
if (value == nullptr) {
|
if (value == nullptr) {
|
||||||
os << "nullptr";
|
os << "POINTER:"<< "nullptr";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
os << "Type0:" <<type_descriptor::name << "=";
|
||||||
os << '&';
|
os << '&';
|
||||||
debug_impl(os, *value, -1);
|
debug_impl(os, *value, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if constexpr (trait::is_reflectable_v<T>) {
|
else if constexpr (trait::is_reflectable_v<T>) {
|
||||||
|
os << "Type2:" <<type_descriptor::name << "=";
|
||||||
debug_reflectable(os, value, depth);
|
debug_reflectable(os, value, depth);
|
||||||
}
|
}
|
||||||
else if constexpr (detail::is_ostream_printable_v<CharT, T>) {
|
else if constexpr (detail::is_ostream_printable_v<CharT, T>) {
|
||||||
|
//os << "Type3:" <<type_descriptor::name << "=";
|
||||||
|
os << "TypeSimple:" << typeid(T).name() << "//";
|
||||||
os << value;
|
os << value;
|
||||||
}
|
}
|
||||||
else if constexpr (trait::is_container_v<T>) {
|
else if constexpr (trait::is_container_v<T>) {
|
||||||
|
//os << "Type4:" <<type_descriptor::name << "=";
|
||||||
|
os << "TypeContainer:" << typeid(T).name() << "//";
|
||||||
debug_container(os, value, depth);
|
debug_container(os, value, depth);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -799,7 +824,7 @@ namespace runtime2
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void print_fields(const T& t) {
|
void print_fields(const T& t) {
|
||||||
runtime2::debug(std::cout, t);
|
runtime2::debug(std::cout, t);
|
||||||
constexpr auto type = refl::reflect<T>();
|
//constexpr auto type = refl::reflect<T>();
|
||||||
|
|
||||||
// constexpr auto membertype = refl::member_list<T>();
|
// constexpr auto membertype = refl::member_list<T>();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue