weights of `type`, `nrows` rows of n elements, quantized by ggml from gaussian floats of scale `amp`
| 273 | |
| 274 | // weights of `type`, `nrows` rows of n elements, quantized by ggml from gaussian floats of scale `amp` |
| 275 | std::vector<uint8_t> make_rows(ggml_type type, int n, int nrows, Rng& r, float amp) { |
| 276 | ggml_quantize_init(type); |
| 277 | std::vector<float> f((size_t) n * nrows), im((size_t) n, 1.0f); |
| 278 | for (float& v : f) v = r.gauss() * amp; |
| 279 | std::vector<uint8_t> out(ggml_row_size(type, n) * nrows); |
| 280 | const size_t got = ggml_quantize_chunk(type, f.data(), out.data(), 0, nrows, n, ggml_quantize_requires_imatrix(type) ? im.data() : nullptr); |
| 281 | if (got != out.size()) { |
| 282 | std::printf("quantize_chunk(%s) returned %zu, expected %zu\n", ggml_type_name(type), got, out.size()); |
| 283 | std::exit(2); |
| 284 | } |
| 285 | return out; |
| 286 | } |
| 287 | |
| 288 | bool bits_equal(float a, float b) { return std::memcmp(&a, &b, 4) == 0; } |
| 289 |