MCPcopy Create free account
hub / github.com/Vahe1994/AQLM / code1x16_matmat

Function code1x16_matmat

inference_lib/src/aqlm/inference_kernels/cuda_kernel.cpp:148–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148torch::Tensor code1x16_matmat(
149 const torch::Tensor& input,
150 const torch::Tensor& codes,
151 const torch::Tensor& codebooks,
152 const torch::Tensor& scales,
153 const std::optional<torch::Tensor>& bias
154) {
155 bool use_bfloat16 = check_use_bfloat16(input);
156 auto input_sizes = input.sizes();
157 auto out_features = codes.size(0) * codebooks.size(2);
158 auto flat_input = input.reshape({-1, input.size(-1)});
159 auto flat_output = torch::empty({flat_input.size(0), out_features},
160 torch::TensorOptions()
161 .dtype(input.dtype())
162 .device(input.device())
163 );
164
165 for (int i = 0; i < flat_input.size(0); ++i) {
166 auto input_vec = flat_input.index({i});
167 auto output_vec = flat_output.index({i});
168 code1x16_matvec(
169 codes.squeeze(2),
170 input_vec,
171 output_vec,
172 codebooks,
173 use_bfloat16
174 );
175 }
176 return scale_bias_unflatten_output(
177 flat_output,
178 scales,
179 bias,
180 input_sizes
181 );
182}
183
184torch::Tensor code1x16_dequant(
185 const torch::Tensor& codes,

Callers

nothing calls this directly

Calls 3

check_use_bfloat16Function · 0.85
code1x16_matvecFunction · 0.85

Tested by

no test coverage detected