Skip to content

Commit 7778717

Browse files
author
mike dupont
committed
typeinfo\n\nnow printing out some type information (ugly) for each field, more work needed
1 parent ec2b03e commit 7778717

File tree

2 files changed

+54
-29
lines changed

2 files changed

+54
-29
lines changed

ggml.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17987,19 +17987,19 @@ static_assert(GGUF_TYPE_COUNT == 13, "GGUF_TYPE_COUNT != 13");
1798717987

1798817988

1798917989
void GGUF_TYPE_NAME_init(){
17990-
GGUF_TYPE_NAME[GGUF_TYPE_UINT8] = "u8";
17991-
GGUF_TYPE_NAME[GGUF_TYPE_INT8] = "i8";
17992-
GGUF_TYPE_NAME[GGUF_TYPE_UINT16] = "u16";
17993-
GGUF_TYPE_NAME[GGUF_TYPE_INT16] = "i16";
17994-
GGUF_TYPE_NAME[GGUF_TYPE_UINT32] = "u32";
17995-
GGUF_TYPE_NAME[GGUF_TYPE_INT32] = "i32";
17996-
GGUF_TYPE_NAME[GGUF_TYPE_FLOAT32] = "f32";
17997-
GGUF_TYPE_NAME[GGUF_TYPE_BOOL] = "bool";
17998-
GGUF_TYPE_NAME[GGUF_TYPE_STRING] = "str";
17999-
GGUF_TYPE_NAME[GGUF_TYPE_ARRAY] = "arr";
18000-
GGUF_TYPE_NAME[GGUF_TYPE_UINT64] = "u64";
18001-
GGUF_TYPE_NAME[GGUF_TYPE_INT64] = "i64";
18002-
GGUF_TYPE_NAME[GGUF_TYPE_FLOAT64] = "f64";
17990+
GGUF_TYPE_NAME[GGUF_TYPE_UINT8] = (char*)"u8";
17991+
GGUF_TYPE_NAME[GGUF_TYPE_INT8] = (char*) "i8";
17992+
GGUF_TYPE_NAME[GGUF_TYPE_UINT16] = (char*) "u16";
17993+
GGUF_TYPE_NAME[GGUF_TYPE_INT16] = (char*) "i16";
17994+
GGUF_TYPE_NAME[GGUF_TYPE_UINT32] = (char*) "u32";
17995+
GGUF_TYPE_NAME[GGUF_TYPE_INT32] = (char*) "i32";
17996+
GGUF_TYPE_NAME[GGUF_TYPE_FLOAT32] = (char*) "f32";
17997+
GGUF_TYPE_NAME[GGUF_TYPE_BOOL] = (char*) "bool";
17998+
GGUF_TYPE_NAME[GGUF_TYPE_STRING] = (char*) "str";
17999+
GGUF_TYPE_NAME[GGUF_TYPE_ARRAY] = (char*) "arr";
18000+
GGUF_TYPE_NAME[GGUF_TYPE_UINT64] = (char*) "u64";
18001+
GGUF_TYPE_NAME[GGUF_TYPE_INT64] = (char*) "i64";
18002+
GGUF_TYPE_NAME[GGUF_TYPE_FLOAT64] = (char*) "f64";
1800318003
};
1800418004
static_assert(GGUF_TYPE_COUNT == 13, "GGUF_TYPE_COUNT != 13");
1800518005

print.hpp

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,28 @@ REFL_END
2121
REFL_TYPE(ggml_opt_context::ggml_grad )
2222
REFL_END
2323
#endif
24+
25+
REFL_TYPE(ggml_task_type )
26+
REFL_END
27+
REFL_TYPE(ggml_type )
28+
REFL_END
29+
REFL_TYPE(ggml_backend_type )
30+
REFL_END
31+
//REFL_TYPE(long int * )
32+
//REFL_END
2433
REFL_TYPE(gpt_params )
2534

26-
REFL_FIELD( seed )
27-
REFL_FIELD( n_threads)
28-
REFL_FIELD( n_threads_batch)
29-
REFL_FIELD( n_predict )
30-
REFL_FIELD( n_ctx )
31-
REFL_FIELD( n_batch)
32-
REFL_FIELD( n_keep )
33-
REFL_FIELD( n_draft)
34-
REFL_FIELD( n_chunks )
35-
REFL_FIELD( n_parallel)
36-
REFL_FIELD( n_sequences)
35+
//REFL_FIELD( seed )
36+
//REFL_FIELD( n_threads)
37+
//REFL_FIELD( n_threads_batch)
38+
//REFL_FIELD( n_predict )
39+
//REFL_FIELD( n_ctx )
40+
//REFL_FIELD( n_batch)
41+
//REFL_FIELD( n_keep )
42+
//REFL_FIELD( n_draft)
43+
//REFL_FIELD( n_chunks )
44+
//REFL_FIELD( n_parallel)
45+
//REFL_FIELD( n_sequences)
3746
REFL_FIELD( p_accept )
3847
REFL_FIELD( p_split )
3948
REFL_FIELD( n_gpu_layers)
@@ -586,6 +595,7 @@ REFL_END
586595
template <typename T>
587596
constexpr auto get_value_type_name(const T t) noexcept
588597
{
598+
589599
return t.value_type;
590600
}
591601

@@ -635,15 +645,19 @@ namespace runtime2
635645
using type_descriptor = type_descriptor<T>;
636646
bool compact = depth == -1;
637647
// print type with members enclosed in braces
638-
os << type_descriptor::name << " { ";
648+
os << "Type2:" <<type_descriptor::name << " { ";
639649
if (!compact) os << '\n';
640650

641651
constexpr auto readable_members = filter(type_descriptor::members, [](auto member) { return is_readable(member); });
642652
for_each(readable_members, [&](auto member, [[maybe_unused]] auto index) {
643653
int new_depth = next_depth(depth);
644654

645655
indent(os, new_depth);
646-
os << get_display_name(member) << " = ";
656+
os << get_display_name(member) << "/";
657+
//using typename member_descriptor_base<T, 0>::member;
658+
//static_assert(trait::is_field_v<member>);
659+
660+
//os << get_value_type_name(member) << " = ";
647661

648662
if constexpr (util::contains_instance<attr::debug>(member.attributes)) {
649663
// use the debug attribute to print
@@ -679,6 +693,9 @@ namespace runtime2
679693
}
680694
else if constexpr (detail::is_ostream_printable_v<CharT, T>) {
681695
// type supports printing natively, just use that
696+
//constexpr auto vtype = refl::reflect<T>();
697+
using type_descriptor = refl::descriptor::type_descriptor<T>;
698+
os << "Type:" << type_descriptor::name << ":";
682699

683700
os << value;
684701

@@ -719,26 +736,34 @@ namespace runtime2
719736
void debug_impl(std::basic_ostream<CharT>& os, const T& value, [[maybe_unused]] int depth)
720737
{
721738
using no_pointer_t = std::remove_pointer_t<T>;
739+
using type_descriptor = type_descriptor<T>;
722740

723741
if constexpr (std::is_same_v<bool, T>) {
724-
os << (value ? "true" : "false");
742+
743+
os << "BOOL"<< (value ? "true" : "false");
725744
}
726745
else if constexpr (std::is_pointer_v<T> && !std::is_void_v<no_pointer_t> && trait::is_reflectable_v<no_pointer_t>) {
727746
if (value == nullptr) {
728-
os << "nullptr";
747+
os << "POINTER:"<< "nullptr";
729748
}
730749
else {
750+
os << "Type0:" <<type_descriptor::name << "=";
731751
os << '&';
732752
debug_impl(os, *value, -1);
733753
}
734754
}
735755
else if constexpr (trait::is_reflectable_v<T>) {
756+
os << "Type2:" <<type_descriptor::name << "=";
736757
debug_reflectable(os, value, depth);
737758
}
738759
else if constexpr (detail::is_ostream_printable_v<CharT, T>) {
760+
//os << "Type3:" <<type_descriptor::name << "=";
761+
os << "TypeSimple:" << typeid(T).name() << "//";
739762
os << value;
740763
}
741764
else if constexpr (trait::is_container_v<T>) {
765+
//os << "Type4:" <<type_descriptor::name << "=";
766+
os << "TypeContainer:" << typeid(T).name() << "//";
742767
debug_container(os, value, depth);
743768
}
744769
else {
@@ -799,7 +824,7 @@ namespace runtime2
799824
template<typename T>
800825
void print_fields(const T& t) {
801826
runtime2::debug(std::cout, t);
802-
constexpr auto type = refl::reflect<T>();
827+
//constexpr auto type = refl::reflect<T>();
803828

804829
// constexpr auto membertype = refl::member_list<T>();
805830

0 commit comments

Comments
 (0)