llama: support kv overrides type string string
This commit is contained in:
parent
d766c5a62e
commit
01e7795930
2 changed files with 10 additions and 2 deletions
|
@ -2801,6 +2801,7 @@ namespace GGUFMeta {
|
||||||
case LLAMA_KV_OVERRIDE_TYPE_BOOL: return "bool";
|
case LLAMA_KV_OVERRIDE_TYPE_BOOL: return "bool";
|
||||||
case LLAMA_KV_OVERRIDE_TYPE_INT: return "int";
|
case LLAMA_KV_OVERRIDE_TYPE_INT: return "int";
|
||||||
case LLAMA_KV_OVERRIDE_TYPE_FLOAT: return "float";
|
case LLAMA_KV_OVERRIDE_TYPE_FLOAT: return "float";
|
||||||
|
case LLAMA_KV_OVERRIDE_TYPE_STR: return "str";
|
||||||
}
|
}
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
@ -2820,6 +2821,9 @@ namespace GGUFMeta {
|
||||||
case LLAMA_KV_OVERRIDE_TYPE_FLOAT: {
|
case LLAMA_KV_OVERRIDE_TYPE_FLOAT: {
|
||||||
LLAMA_LOG_INFO("%.6f\n", ovrd->float_value);
|
LLAMA_LOG_INFO("%.6f\n", ovrd->float_value);
|
||||||
} break;
|
} break;
|
||||||
|
case LLAMA_KV_OVERRIDE_TYPE_STR: {
|
||||||
|
LLAMA_LOG_INFO("%s\n", ovrd->str_value);
|
||||||
|
} break;
|
||||||
default:
|
default:
|
||||||
// Shouldn't be possible to end up here, but just in case...
|
// Shouldn't be possible to end up here, but just in case...
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
|
@ -13698,6 +13702,8 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
|
||||||
gguf_set_val_i32(ctx_out, o.key, o.int_value);
|
gguf_set_val_i32(ctx_out, o.key, o.int_value);
|
||||||
} else if (o.tag == LLAMA_KV_OVERRIDE_TYPE_BOOL) {
|
} else if (o.tag == LLAMA_KV_OVERRIDE_TYPE_BOOL) {
|
||||||
gguf_set_val_bool(ctx_out, o.key, o.bool_value);
|
gguf_set_val_bool(ctx_out, o.key, o.bool_value);
|
||||||
|
} else if (o.tag == LLAMA_KV_OVERRIDE_TYPE_STR) {
|
||||||
|
gguf_set_val_str(ctx_out, o.key, o.str_value);
|
||||||
} else {
|
} else {
|
||||||
LLAMA_LOG_WARN("%s: unknown KV override type for key %s\n", __func__, o.key);
|
LLAMA_LOG_WARN("%s: unknown KV override type for key %s\n", __func__, o.key);
|
||||||
}
|
}
|
||||||
|
|
6
llama.h
6
llama.h
|
@ -195,6 +195,7 @@ extern "C" {
|
||||||
LLAMA_KV_OVERRIDE_TYPE_INT,
|
LLAMA_KV_OVERRIDE_TYPE_INT,
|
||||||
LLAMA_KV_OVERRIDE_TYPE_FLOAT,
|
LLAMA_KV_OVERRIDE_TYPE_FLOAT,
|
||||||
LLAMA_KV_OVERRIDE_TYPE_BOOL,
|
LLAMA_KV_OVERRIDE_TYPE_BOOL,
|
||||||
|
LLAMA_KV_OVERRIDE_TYPE_STR,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct llama_model_kv_override {
|
struct llama_model_kv_override {
|
||||||
|
@ -202,8 +203,9 @@ extern "C" {
|
||||||
enum llama_model_kv_override_type tag;
|
enum llama_model_kv_override_type tag;
|
||||||
union {
|
union {
|
||||||
int64_t int_value;
|
int64_t int_value;
|
||||||
double float_value;
|
double float_value;
|
||||||
bool bool_value;
|
bool bool_value;
|
||||||
|
char * str_value = nullptr;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue