diff --git a/src/llama-context.cpp b/src/llama-context.cpp index 6912d4feb5..181e732609 100644 --- a/src/llama-context.cpp +++ b/src/llama-context.cpp @@ -2393,11 +2393,11 @@ llm_graph_result * llama_context::get_gf_res_reserve() const { } // pack sampler outputs into as few sequences as possible before using sequences without samplers -static void ubatch_prepare_reserve( - llama_ubatch & ubatch, - uint32_t n_outputs, - const std::map & samplers, - uint32_t n_outputs_max_per_seq) { +static void graph_reserve_prepare_ubatch( + llama_ubatch & ubatch, + const llama_samplers & samplers, + uint32_t n_outputs, + uint32_t n_outputs_max_per_seq) { const uint32_t n_seqs = ubatch.n_seqs; const uint32_t n_seq_tokens = ubatch.n_seq_tokens; @@ -2474,7 +2474,7 @@ llama_context::graph_reserve_result llama_context::graph_reserve(graph_reserve_p llama_batch_allocr balloc(model.hparams.n_pos_per_embd()); llama_ubatch ubatch = balloc.ubatch_reserve(params.n_tokens/params.n_seqs, params.n_seqs); - ubatch_prepare_reserve(ubatch, params.n_outputs, sampling.samplers, cparams.n_outputs_max_per_seq); + graph_reserve_prepare_ubatch(ubatch, sampling.samplers, params.n_outputs, cparams.n_outputs_max_per_seq); auto * res = gf_res_reserve.get(); diff --git a/src/llama-context.h b/src/llama-context.h index 779a504eeb..7ebcfe247c 100644 --- a/src/llama-context.h +++ b/src/llama-context.h @@ -320,7 +320,7 @@ private: struct sampling_info { // !samplers.empty() to check if any samplers are active - std::map samplers; + llama_samplers samplers; buffer_view logits = {nullptr, 0}; buffer_view sampled = {nullptr, 0}; diff --git a/src/llama-graph.h b/src/llama-graph.h index 75bc0fe80d..08da64c772 100644 --- a/src/llama-graph.h +++ b/src/llama-graph.h @@ -31,6 +31,9 @@ class llama_memory_recurrent_context; class llama_memory_hybrid_context; class llama_memory_hybrid_iswa_context; +// shorthands +using llama_samplers = std::map; + // certain models (typically multi-modal) can produce different types of graphs enum llm_graph_type { LLM_GRAPH_TYPE_DEFAULT, @@ -709,14 +712,14 @@ public: class llm_graph_input_sampling : public llm_graph_input_i { public: - llm_graph_input_sampling(std::map samplers) : + llm_graph_input_sampling(llama_samplers samplers) : samplers(std::move(samplers)) { } virtual ~llm_graph_input_sampling() = default; void set_input(const llama_ubatch * ubatch) override; bool can_reuse(const llm_graph_params & params) override; - std::map samplers; + llama_samplers samplers; }; // @@ -752,11 +755,11 @@ struct llm_graph_params { const llama_memory_context_i * mctx; const llama_cross * cross; - std::map samplers; + llama_samplers samplers; static bool samplers_equal( - const std::map & lhs, - const std::map & rhs) { + const llama_samplers & lhs, + const llama_samplers & rhs) { if (lhs.size() != rhs.size()) { return false; } @@ -992,7 +995,7 @@ struct llm_graph_context { const llama_memory_context_i * mctx; const llama_cross * cross; - std::map samplers; + llama_samplers samplers; const llm_graph_cb & cb_func;