Skip to content

Commit 79d17ac

Browse files
authored
Merge branch 'ggml-org:master' into master
2 parents 8fec14c + 4b8560a commit 79d17ac

File tree

4 files changed

+97
-856
lines changed

4 files changed

+97
-856
lines changed

common/chat.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,10 +1741,12 @@ static void common_chat_parse_gpt_oss(common_chat_msg_parser & builder) {
17411741
static common_chat_params common_chat_params_init_firefunction_v2(const common_chat_template & tmpl, const struct templates_params & inputs) {
17421742
LOG_DBG("%s\n", __func__);
17431743
common_chat_params data;
1744-
data.prompt = apply(tmpl, inputs, /* messages_override =*/ std::nullopt, /* tools_override= */ json(), json {
1744+
const std::optional<json> tools_override = json();
1745+
const std::optional<json> additional_context = json {
17451746
{"datetime", format_time(inputs.now, "%b %d %Y %H:%M:%S GMT")},
17461747
{"functions", json(inputs.tools.empty() ? "" : inputs.tools.dump(2))},
1747-
});
1748+
};
1749+
data.prompt = apply(tmpl, inputs, /* messages_override =*/ std::nullopt, tools_override, additional_context);
17481750
if (inputs.tools.is_array() && !inputs.tools.empty()) {
17491751
data.grammar_lazy = inputs.tool_choice != COMMON_CHAT_TOOL_CHOICE_REQUIRED;
17501752
data.grammar = build_grammar([&](const common_grammar_builder & builder) {

ggml/src/ggml-cpu/common.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ static inline float bf16_to_f32(ggml_bf16_t x) {
2828
return GGML_BF16_TO_FP32(x);
2929
}
3030

31+
static inline float i32_to_f32(int32_t x) {
32+
return x;
33+
}
34+
35+
static inline int32_t f32_to_i32(float x) {
36+
return x;
37+
}
38+
3139
static inline float f32_to_f32(float x) {
3240
return x;
3341
}
@@ -54,6 +62,12 @@ struct type_conversion_table<ggml_bf16_t> {
5462
static constexpr ggml_bf16_t (*from_f32)(float) = f32_to_bf16;
5563
};
5664

65+
template <>
66+
struct type_conversion_table<int32_t> {
67+
static constexpr float (*to_f32)(int32_t) = i32_to_f32;
68+
static constexpr int32_t (*from_f32)(float) = f32_to_i32;
69+
};
70+
5771
static std::pair<int64_t, int64_t> get_thread_range(const struct ggml_compute_params * params, const struct ggml_tensor * src0) {
5872
const int64_t ith = params->ith;
5973
const int64_t nth = params->nth;

0 commit comments

Comments
 (0)