rows `rows` of a 2-D F32 tensor (ne1 indexes rows)
| 402 | } |
| 403 | // rows `rows` of a 2-D F32 tensor (ne1 indexes rows) |
| 404 | float* f32_rows(const Tensor& t, const std::vector<int>& rows, size_t row_floats) { |
| 405 | if (t.type != T_F32) throw std::runtime_error(t.name + " is not F32"); |
| 406 | if ((size_t) t.ne[0] != row_floats) |
| 407 | throw std::runtime_error(t.name + " is " + std::to_string(t.ne[0]) + " floats a row, not the " + std::to_string(row_floats) + |
| 408 | " its reader takes"); |
| 409 | std::vector<float> h(rows.size() * (size_t) t.ne[0]); |
| 410 | for (size_t i = 0; i < rows.size(); ++i) |
| 411 | std::memcpy(&h[i * t.ne[0]], row_of(t, rows[i], (size_t) t.ne[0] * 4), (size_t) t.ne[0] * 4); |
| 412 | return put<float>(h.data(), h.size() * 4); |
| 413 | } |
| 414 | // Q8_0 -> bf16, the whole tensor; F32 -> bf16 likewise |
| 415 | uint16_t* bf16(const Tensor& t) { |
| 416 | const size_t n = (size_t) (t.ne[0] * t.ne[1] * t.ne[2] * t.ne[3]); |