| 380 | |
| 381 | template <Type qType, int numBits, int numChunks, int threads_per_group, int max_threads> |
| 382 | DS_D_INLINE void local_array(cg::thread_block& tb, |
| 383 | cg::thread_block_tile<hw_warp_size>& warp, |
| 384 | __half2* local_buffer, |
| 385 | float* __restrict__ global_params, |
| 386 | int8_t* __restrict__ output_data, |
| 387 | const int& elems_per_group, |
| 388 | const int& groups, |
| 389 | Params<qType, numBits> q_params) |
| 390 | { |
| 391 | constexpr int num_ele_int8 = 8 / numBits; |
| 392 | constexpr int num_int8_out = quantize::h_per_load / num_ele_int8; |
| 393 | |
| 394 | // Indexing offsets |
| 395 | const int block_num = |
| 396 | (tb.group_index().x * max_threads / threads_per_group) + tb.thread_index().y; |
| 397 | const int block_offset = block_num * elems_per_group; |
| 398 | const int elem_offset = tb.thread_index().x * quantize::h_per_load; |
| 399 | const int base_offset = (block_offset + elem_offset) / num_ele_int8; |
| 400 | const int stride = tb.size() * quantize::h_per_load / num_ele_int8; |
| 401 | |
| 402 | int8_t local_output[num_int8_out]; |
| 403 | |
| 404 | if (tb.thread_index().x == 0 && block_num < groups) { |
| 405 | q_params.store( |
| 406 | global_params, |
| 407 | (tb.group_index().x * max_threads / threads_per_group) + tb.thread_index().y); |
| 408 | } |
| 409 | #pragma unroll |
| 410 | for (int i = 0; i < numChunks; i++) { |
| 411 | if (elem_offset + i * stride * num_ele_int8 < elems_per_group && block_num < groups) { |
| 412 | quantize::_chunk<numBits, qType>( |
| 413 | local_output, local_buffer + i * quantize::h2_per_load, q_params); |
| 414 | mem_access::store_global<num_int8_out>(output_data + (base_offset + i * stride), |
| 415 | local_output); |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | template <Type qType, int numBits, int numChunks, int threads_per_group, int max_threads> |
| 421 | DS_D_INLINE void local_array(cg::thread_block& tb, |