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

Method q8split

engine/src/split/src/model.cpp:478–492  ·  view source on GitHub ↗

a whole Q8_0 tensor as int8 values and f16 scales

Source from the content-addressed store, hash-verified

476 }
477 // a whole Q8_0 tensor as int8 values and f16 scales
478 Q8S q8split(const Tensor& t) {
479 if (t.type != T_Q8_0) throw std::runtime_error(t.name + ": q8split needs Q8_0");
480 const size_t n = (size_t) (t.ne[0] * t.ne[1] * t.ne[2] * t.ne[3]);
481 std::vector<int8_t> q(n);
482 std::vector<uint16_t> d(n / 32);
483 for (size_t b = 0; b < n / 32; ++b) {
484 const uint8_t* blk = t.data + b * 34;
485 std::memcpy(&d[b], blk, 2);
486 std::memcpy(&q[b * 32], blk + 2, 32);
487 }
488 Q8S s;
489 s.q = put<int8_t>(q.data(), q.size());
490 s.d = put<uint16_t>(d.data(), d.size() * 2);
491 return s;
492 }
493 // whole rows of a quantized 2-D tensor (or of matrix `mat` of a 3-D one)
494 DW rows(const Tensor& t, const std::vector<int>& rows) {
495 DW w;

Callers 1

load_cardFunction · 0.80

Calls 3

memcpyFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected