MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / local_array

Function local_array

deepspeed/ops/csrc/includes/quantization_utils.h:381–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected