rows `rows` of t1 then of t2 as f32 (F32 rows as they are, Q8_0 rows dequantized)
| 538 | #endif |
| 539 | // rows `rows` of t1 then of t2 as f32 (F32 rows as they are, Q8_0 rows dequantized) |
| 540 | float* f32_rows2(const Tensor& t1, const Tensor& t2, const std::vector<int>& rows, size_t row_floats) { |
| 541 | std::vector<float> h; |
| 542 | for (const Tensor* t : {&t1, &t2}) { |
| 543 | const size_t n = (size_t) t->ne[0]; |
| 544 | if (n != row_floats) |
| 545 | throw std::runtime_error(t->name + " is " + std::to_string(n) + " floats a row, not the " + std::to_string(row_floats) + |
| 546 | " its reader takes"); |
| 547 | for (int r : rows) { |
| 548 | if (t->type == T_F32) { |
| 549 | const float* row = (const float*) row_of(*t, r, n * 4); |
| 550 | h.insert(h.end(), row, row + n); |
| 551 | } else if (t->type == T_Q8_0 && n % 32 == 0) { |
| 552 | const uint8_t* row = row_of(*t, r, t->row_bytes()); |
| 553 | for (size_t b = 0; b < n / 32; ++b) { |
| 554 | uint16_t dh; |
| 555 | std::memcpy(&dh, row + b * 34, 2); |
| 556 | const float d = f16_to_f32(dh); |
| 557 | for (int j = 0; j < 32; ++j) h.push_back(d * (float) (int8_t) row[b * 34 + 2 + j]); |
| 558 | } |
| 559 | } else { |
| 560 | throw std::runtime_error(t->name + " is neither F32 nor Q8_0"); |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | return put<float>(h.data(), h.size() * 4); |
| 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); |