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

Method cols

engine/src/split/src/model.cpp:567–584  ·  view source on GitHub ↗

every row, keeping input blocks `blocks` (block indices along ne0) of each: a column slice

Source from the content-addressed store, hash-verified

565 }
566 // every row, keeping input blocks `blocks` (block indices along ne0) of each: a column slice
567 DW cols(const Tensor& t, const std::vector<int>& blocks) {
568 const TypeInfo ti = block32(t);
569 DW w;
570 w.type = t.type;
571 w.n_in = (int) blocks.size() * ti.block;
572 w.n_out = (int) t.ne[1];
573 w.row_bytes = blocks.size() * ti.bytes;
574 const size_t src_row = t.row_bytes();
575 for (int b : blocks)
576 if (b < 0 || (size_t) (b + 1) * ti.bytes > src_row)
577 throw std::runtime_error(t.name + ": block " + std::to_string(b) + " asked for, a row has " + std::to_string(src_row / ti.bytes));
578 std::vector<uint8_t> h((size_t) w.n_out * w.row_bytes);
579 for (int r = 0; r < w.n_out; ++r)
580 for (size_t b = 0; b < blocks.size(); ++b)
581 std::memcpy(&h[(size_t) r * w.row_bytes + b * ti.bytes], t.data + (size_t) r * src_row + (size_t) blocks[b] * ti.bytes, ti.bytes);
582 w.p = put<uint8_t>(h.data(), h.size());
583 return w;
584 }
585 // per expert: rows [r0, r1) (gate / up), expert-major
586 static void row_range(const Tensor& t, int r0, int r1) {
587 if (r0 < 0 || r1 <= r0 || r1 > t.ne[1])

Callers 3

load_layers_27bFunction · 0.45
load_cardFunction · 0.45
load_mtp_cardFunction · 0.45

Calls 6

block32Function · 0.85
memcpyFunction · 0.85
to_stringFunction · 0.50
sizeMethod · 0.45
row_bytesMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected