| 98 | return; \ |
| 99 | } |
| 100 | void selective_dequantize(torch::Tensor& val, |
| 101 | torch::Tensor& val_q, |
| 102 | torch::Tensor& indexes, |
| 103 | int group_size, |
| 104 | int q_mantisa_bits, |
| 105 | int q_exponent_bits) |
| 106 | { |
| 107 | int total_elems = at::numel(val); |
| 108 | int num_indexes = indexes.size(0); |
| 109 | TORCH_CHECK(group_size > 0, "group_size must be positive"); |
| 110 | TORCH_CHECK(group_size % 8 == 0, "group_size must be divisible by 8"); |
| 111 | TORCH_CHECK(total_elems % group_size == 0, |
| 112 | "tensor element count must be divisible by group_size"); |
| 113 | int num_groups = total_elems / group_size; |
| 114 | if (num_groups == 0 || num_indexes == 0) { return; } |
| 115 | |
| 116 | DISPATCH_DEQUANTIZE_INDEX(kHalf, __half, 10); |
| 117 | #ifdef BF16_AVAILABLE |
| 118 | DISPATCH_DEQUANTIZE_INDEX(kBFloat16, __nv_bfloat16, 7); |
| 119 | #endif |
| 120 | } |
| 121 | |
| 122 | at::Tensor get_scales(torch::Tensor& out, int num_groups) |
| 123 | { |