| 64 | } |
| 65 | |
| 66 | void 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) { \ |
nothing calls this directly
no outgoing calls
no test coverage detected