MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / _chunk

Function _chunk

csrc/includes/quantization_utils.h:345–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343
344template <int numBits, Type qType>
345DS_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
364template <int numBits, Type qType>
365DS_D_INLINE void _chunk(int8_t* local_output, const __half2* data, Params<qType, numBits> q_params)

Callers

nothing calls this directly

Calls 1

quantizeMethod · 0.45

Tested by

no test coverage detected