refl now working, not on pointers but on the types
This commit is contained in:
parent
df647db611
commit
90d6f11f66
5 changed files with 95 additions and 18 deletions
4
Makefile
4
Makefile
|
@ -1,5 +1,3 @@
|
|||
tt:
|
||||
clang++ -std=c++17 ggml.cpp
|
||||
|
||||
# Define the default target now so that it is always the first target
|
||||
BUILD_TARGETS = \
|
||||
|
@ -742,3 +740,5 @@ tests/test-tokenizer-1-llama: tests/test-tokenizer-1-llama.cpp ggml.o llama.o $(
|
|||
|
||||
tests/test-c.o: tests/test-c.cpp llama.h
|
||||
$(CXX) $(CFLAGS) -c $(filter-out %.h,$^) -o $@
|
||||
tt:
|
||||
clang++ -std=c++17 ggml.cpp
|
||||
|
|
|
@ -42,7 +42,7 @@ extern char const *LLAMA_BUILD_TARGET;
|
|||
//
|
||||
int32_t get_num_physical_cores();
|
||||
|
||||
struct gpt_params : refl::attr::usage::type{
|
||||
struct gpt_params {
|
||||
uint32_t seed = -1; // RNG seed
|
||||
|
||||
int32_t n_threads = get_num_physical_cores();
|
||||
|
|
|
@ -40,11 +40,14 @@ static bool gguf_ex_write(const std::string & fname) {
|
|||
gguf_set_arr_data(ctx, "some.parameter.arr.f32", GGUF_TYPE_FLOAT32, std::vector<float>{ 3.145f, 2.718f, 1.414f, }.data(), 3);
|
||||
gguf_set_arr_str (ctx, "some.parameter.arr.str", std::vector<const char *>{ "hello", "world", "!" }.data(), 3);
|
||||
|
||||
struct ggml_init_params params = {
|
||||
.mem_size = 128ull*1024ull*1024ull,
|
||||
.mem_buffer = NULL,
|
||||
.no_alloc = false,
|
||||
};
|
||||
struct ggml_init_params params(
|
||||
//.mem_size =
|
||||
128ull*1024ull*1024ull,
|
||||
//.mem_buffer =
|
||||
NULL,
|
||||
//.no_alloc =
|
||||
false
|
||||
);
|
||||
|
||||
struct ggml_context * ctx_data = ggml_init(params);
|
||||
|
||||
|
@ -86,10 +89,12 @@ static bool gguf_ex_write(const std::string & fname) {
|
|||
|
||||
// just read tensor info
|
||||
static bool gguf_ex_read_0(const std::string & fname) {
|
||||
struct gguf_init_params params = {
|
||||
.no_alloc = false,
|
||||
.ctx = NULL,
|
||||
};
|
||||
struct gguf_init_params params (
|
||||
//.no_alloc =
|
||||
false,
|
||||
//.ctx =
|
||||
NULL
|
||||
);
|
||||
|
||||
struct gguf_context * ctx = gguf_init_from_file(fname.c_str(), params);
|
||||
|
||||
|
@ -146,10 +151,12 @@ static bool gguf_ex_read_0(const std::string & fname) {
|
|||
static bool gguf_ex_read_1(const std::string & fname) {
|
||||
struct ggml_context * ctx_data = NULL;
|
||||
|
||||
struct gguf_init_params params = {
|
||||
.no_alloc = false,
|
||||
.ctx = &ctx_data,
|
||||
};
|
||||
struct gguf_init_params params (
|
||||
//.no_alloc =
|
||||
false,
|
||||
//.ctx =
|
||||
&ctx_data
|
||||
);
|
||||
|
||||
struct gguf_context * ctx = gguf_init_from_file(fname.c_str(), params);
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ int main(int argc, char ** argv) {
|
|||
g_params = ¶ms;
|
||||
|
||||
//using Td = type_descriptor<gpt_params>;
|
||||
print_fields(g_params);
|
||||
print_fields(params);
|
||||
|
||||
//constexpr auto tbl = descriptor::get_attribute<gpt_params>(Td{});
|
||||
//constexpr auto tbl_name = REFL_MAKE_CONST_STRING(tbl.name);
|
||||
|
|
72
print.hpp
72
print.hpp
|
@ -18,6 +18,76 @@ REFL_TYPE(ggml_opt_context::ggml_grad )
|
|||
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( p_accept )
|
||||
REFL_FIELD( p_split )
|
||||
REFL_FIELD( n_gpu_layers)
|
||||
REFL_FIELD( n_gpu_layers_draft)
|
||||
REFL_FIELD( main_gpu )
|
||||
REFL_FIELD( tensor_split)
|
||||
REFL_FIELD( n_beams )
|
||||
REFL_FIELD(rope_freq_base)
|
||||
REFL_FIELD( rope_freq_scale )
|
||||
REFL_FIELD( yarn_ext_factor )
|
||||
REFL_FIELD( yarn_attn_factor )
|
||||
REFL_FIELD( yarn_beta_fast )
|
||||
REFL_FIELD( yarn_beta_slow )
|
||||
REFL_FIELD( yarn_orig_ctx)
|
||||
REFL_FIELD( rope_scaling_type)
|
||||
REFL_FIELD( sparams)
|
||||
REFL_FIELD(model )
|
||||
REFL_FIELD(model_draft )
|
||||
REFL_FIELD(model_alias)
|
||||
REFL_FIELD(prompt )
|
||||
REFL_FIELD(prompt_file )
|
||||
REFL_FIELD(path_prompt_cache )
|
||||
REFL_FIELD(input_prefix )
|
||||
REFL_FIELD(input_suffix )
|
||||
REFL_FIELD( antiprompt)
|
||||
REFL_FIELD(logdir )
|
||||
REFL_FIELD( lora_adapter)
|
||||
REFL_FIELD(lora_base )
|
||||
REFL_FIELD( ppl_stride )
|
||||
REFL_FIELD( ppl_output_type )
|
||||
REFL_FIELD( hellaswag )
|
||||
REFL_FIELD( hellaswag_tasks )
|
||||
REFL_FIELD( mul_mat_q )
|
||||
REFL_FIELD( memory_f16)
|
||||
REFL_FIELD( random_prompt )
|
||||
REFL_FIELD( use_color )
|
||||
REFL_FIELD( interactive )
|
||||
REFL_FIELD( chatml )
|
||||
REFL_FIELD( prompt_cache_all )
|
||||
REFL_FIELD( prompt_cache_ro )
|
||||
REFL_FIELD( embedding )
|
||||
REFL_FIELD( escape )
|
||||
REFL_FIELD( interactive_first )
|
||||
REFL_FIELD( multiline_input )
|
||||
REFL_FIELD( simple_io )
|
||||
REFL_FIELD( cont_batching )
|
||||
REFL_FIELD( input_prefix_bos )
|
||||
REFL_FIELD( ignore_eos )
|
||||
REFL_FIELD( instruct )
|
||||
REFL_FIELD( logits_all )
|
||||
REFL_FIELD( use_mmap)
|
||||
REFL_FIELD( use_mlock )
|
||||
REFL_FIELD( numa )
|
||||
REFL_FIELD( verbose_prompt )
|
||||
REFL_FIELD( infill )
|
||||
REFL_FIELD(mmproj )
|
||||
REFL_FIELD( image)
|
||||
|
||||
REFL_END
|
||||
|
||||
|
||||
|
@ -398,7 +468,7 @@ void print_fields(const T& ) {
|
|||
// T instance{};
|
||||
for_each(refl::reflect<T>().members, [&](auto member) {
|
||||
|
||||
std::cout << member.name.str() << "\n";
|
||||
std::cout << "MEMBER" << member.name.str() << "\n";
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue