MCPcopy Create free account
hub / github.com/Niko1221/Strata / make_rows

Function make_rows

engine/tests/quant/quant_parity.cpp:275–286  ·  view source on GitHub ↗

weights of `type`, `nrows` rows of n elements, quantized by ggml from gaussian floats of scale `amp`

Source from the content-addressed store, hash-verified

273
274// weights of `type`, `nrows` rows of n elements, quantized by ggml from gaussian floats of scale `amp`
275std::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
288bool bits_equal(float a, float b) { return std::memcmp(&a, &b, 4) == 0; }
289

Callers 2

test_dotFunction · 0.70
test_dequantFunction · 0.70

Calls 4

exitFunction · 0.85
gaussMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected