MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / TransformerKVCache

Method TransformerKVCache

src/framework/runtime/kv_cache.cpp:11–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10namespace engine::runtime {
11
12namespace {
13
14void validate_cache_tensor(const core::TensorValue & tensor, const TransformerKVCacheOptions & options) {
15 if (tensor.type == GGML_TYPE_F32) {
16 return;
17 }
18 if (options.allow_f16_storage && tensor.type == GGML_TYPE_F16) {
19 return;
20 }
21 if (options.allow_bf16_storage && tensor.type == GGML_TYPE_BF16) {
22 return;
23 }
24 throw std::runtime_error(
25 options.allow_f16_storage || options.allow_bf16_storage
26 ? "TransformerKVCache supports only f32/f16/bf16 cache tensors when enabled"
27 : "TransformerKVCache requires f32 cache tensors");
28}
29
30void write_cache_tensor(
31 const core::TensorValue & tensor,
32 const std::vector<float> & values,
33 const TransformerKVCacheOptions & options) {
34 validate_cache_tensor(tensor, options);
35 if (tensor.type == GGML_TYPE_F32) {
36 core::write_tensor_f32(tensor, values);
37 return;

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected