| 343 | |
| 344 | template <int numBits, Type qType> |
| 345 | DS_D_INLINE void _chunk(int8_t* local_output, const __half* data, Params<qType, numBits> q_params) |
| 346 | { |
| 347 | constexpr int32_t elems = 16 / sizeof(__half); |
| 348 | constexpr int32_t num_elems_packed = 8 / numBits; |
| 349 | |
| 350 | #pragma unroll |
| 351 | for (int i = 0, oi = 0; i < elems; i += num_elems_packed, oi++) { |
| 352 | if (num_elems_packed == 1) { |
| 353 | // TODO(cmikeh2): refactor to use conversion utils |
| 354 | local_output[i] = q_params.quantize(data[i]); |
| 355 | } else if (num_elems_packed == 2) { |
| 356 | int8_t data_i8_1 = q_params.quantize(data[i]); |
| 357 | int8_t data_i8_2 = q_params.quantize(data[i + 1]); |
| 358 | auto data_i8 = PackedInt4{data_i8_2, data_i8_1}; |
| 359 | local_output[oi] = *((int8_t*)(&data_i8)); |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | template <int numBits, Type qType> |
| 365 | DS_D_INLINE void _chunk(int8_t* local_output, const __half2* data, Params<qType, numBits> q_params) |