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

Method expert_rows

engine/src/split/src/model.cpp:591–604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

589 std::to_string(t.ne[1]) + " a matrix");
590 }
591 DW expert_rows(const Tensor& t, int r0, int r1, size_t& stride) {
592 row_range(t, r0, r1);
593 DW w;
594 w.type = t.type;
595 w.n_in = (int) t.ne[0];
596 w.n_out = r1 - r0;
597 w.row_bytes = t.row_bytes();
598 stride = (size_t) w.n_out * w.row_bytes;
599 const size_t src_mat = (size_t) t.ne[1] * w.row_bytes;
600 std::vector<uint8_t> h((size_t) t.ne[2] * stride);
601 for (int64_t e = 0; e < t.ne[2]; ++e) std::memcpy(&h[e * stride], t.data + e * src_mat + (size_t) r0 * w.row_bytes, stride);
602 w.p = put<uint8_t>(h.data(), h.size());
603 return w;
604 }
605 // per expert: rows [r0, r1) of t1 then of t2 (gate; up), expert-major
606 DW expert_rows2(const Tensor& t1, const Tensor& t2, int r0, int r1, size_t& stride, const char** host_of = nullptr) {
607 if (t1.type != t2.type || t1.ne[0] != t2.ne[0] || t1.ne[2] != t2.ne[2]) throw std::runtime_error(t1.name + " and " + t2.name + " do not stack");

Callers

nothing calls this directly

Calls 4

memcpyFunction · 0.85
row_bytesMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected