1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// transcribe-weights-util.h - shared GGUF tensor validation helpers.
//
// INTERNAL. C++17. Consumed only from other .cpp files inside src/.
// Not part of the public include/transcribe.h ABI.
//
// Every per-family weights.cpp needs to resolve tensor names from the
// loaded GGUF's ctx_meta and validate the type + shape matches what
// the family's encoder / decoder graph expects. The pattern is
// identical across families (parakeet and cohere both duplicated it
// verbatim with only the log-tag differing), so it lives here.
//
// Usage: the per-family weights.cpp defines a short GET_* macro
// wrapper that captures the family tag string:
//
// #define PARAKEET_TAG "parakeet"
// #define GET_F32(slot, name, ...) do { \
// ggml_tensor * _t = transcribe::weights::find_tensor( \
// ctx_meta, (name), {GGML_TYPE_F32}, {__VA_ARGS__}, \
// PARAKEET_TAG); \
// if (_t == nullptr) return TRANSCRIBE_ERR_GGUF; \
// (slot) = _t; \
// } while (0)
//
// The GET_* macros stay per-family so the family's log tag ends up in
// diagnostics, but the *type allowlists* are shared via the
// TRANSCRIBE_QUANT_LINEAR_TYPES / TRANSCRIBE_QUANT_CONV_TYPES macros
// below. Every family must accept the full allowlist: the set of types
// tools/transcribe-quantize emits is a project-wide policy, not a
// per-family one. See docs/tools/quantization.md.
// Shared quant allowlists. These are the ggml types that
// tools/transcribe-quantize may place into a released GGUF; every
// family's GET_LIN / GET_CONV macros must accept exactly this set so
// adding a preset to transcribe-quantize doesn't silently bypass a
// family's loader validation.
//
// Expanded at macro-use time inside a brace list passed to
// transcribe::weights::find_tensor(..., allowed_types, ...). Preprocessor
// expansion (rather than a constexpr array) keeps the existing
// find_tensor signature (std::initializer_list<ggml_type>) untouched.
namespace transcribe::weights // namespace transcribe::weights