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

Function dequantize

csrc/fp_quantizer/fp_quantize.cpp:66–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64 }
65
66void dequantize(torch::Tensor& val,
67 torch::Tensor& val_q,
68 int group_size,
69 int q_mantisa_bits,
70 int q_exponent_bits)
71{
72 int total_elems = at::numel(val);
73 TORCH_CHECK(group_size > 0, "group_size must be positive");
74 TORCH_CHECK(group_size % 8 == 0, "group_size must be divisible by 8");
75 TORCH_CHECK(total_elems % group_size == 0,
76 "tensor element count must be divisible by group_size");
77
78 int num_groups = total_elems / group_size;
79 if (num_groups == 0) { return; }
80
81 DISPATCH_DEQUANTIZE(kHalf, __half, 10);
82#ifdef BF16_AVAILABLE
83 DISPATCH_DEQUANTIZE(kBFloat16, __nv_bfloat16, 7);
84#endif
85}
86
87#define DISPATCH_DEQUANTIZE_INDEX(T_TYPE, C_TYPE, mantisa) \
88 if (val.options().dtype() == torch::T_TYPE) { \

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected