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

Method expert_cols

engine/src/split/src/model.cpp:638–658  ·  view source on GitHub ↗

per expert: every row, input blocks [b0, b1) (down), expert-major

Source from the content-addressed store, hash-verified

636 }
637 // per expert: every row, input blocks [b0, b1) (down), expert-major
638 DW expert_cols(const Tensor& t, int b0, int b1, size_t& stride, const char** host_of = nullptr) {
639 const TypeInfo ti = block32(t);
640 DW w;
641 w.type = t.type;
642 w.n_in = (b1 - b0) * ti.block;
643 w.n_out = (int) t.ne[1];
644 w.row_bytes = (size_t) (b1 - b0) * ti.bytes;
645 stride = (size_t) w.n_out * w.row_bytes;
646 const size_t src_row = t.row_bytes(), src_mat = (size_t) t.ne[1] * src_row;
647 if (b0 < 0 || b1 <= b0 || (size_t) b1 * ti.bytes > src_row)
648 throw std::runtime_error(t.name + ": blocks [" + std::to_string(b0) + ", " + std::to_string(b1) + ") asked for, a row has " +
649 std::to_string(src_row / ti.bytes));
650 std::vector<uint8_t> tmp;
651 const size_t bytes = (size_t) t.ne[2] * stride;
652 uint8_t* h = expert_buf(bytes, host_of, tmp);
653 for (int64_t e = 0; e < t.ne[2]; ++e)
654 for (int r = 0; r < w.n_out; ++r)
655 std::memcpy(&h[e * stride + (size_t) r * w.row_bytes], t.data + e * src_mat + (size_t) r * src_row + (size_t) b0 * ti.bytes, w.row_bytes);
656 place(w, h, bytes, stride, host_of);
657 return w;
658 }
659};
660
661std::vector<int> range(int a, int b) {

Callers 2

load_cardFunction · 0.80
load_mtp_cardFunction · 0.80

Calls 5

block32Function · 0.85
memcpyFunction · 0.85
to_stringFunction · 0.50
placeFunction · 0.50
row_bytesMethod · 0.45

Tested by

no test coverage detected