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

Function code2x8_matmat

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

Source from the content-addressed store, hash-verified

385}
386
387torch::Tensor code2x8_matmat(
388 const torch::Tensor& input,
389 const torch::Tensor& codes,
390 const torch::Tensor& codebooks,
391 const torch::Tensor& scales,
392 const std::optional<torch::Tensor>& bias
393) {
394 bool use_bfloat16 = check_use_bfloat16(input);
395 auto input_sizes = input.sizes();
396 auto out_features = codes.size(0) * codebooks.size(2);
397 auto flat_input = input.reshape({-1, input.size(-1)});
398 auto flat_output = torch::empty({flat_input.size(0), out_features},
399 torch::TensorOptions()
400 .dtype(input.dtype())
401 .device(input.device())
402 );
403
404 for (int i = 0; i < flat_input.size(0); ++i) {
405 auto input_vec = flat_input.index({i});
406 auto output_vec = flat_output.index({i});
407 code2x8_matvec(
408 codes.squeeze(2),
409 input_vec,
410 output_vec,
411 codebooks,
412 use_bfloat16
413 );
414 }
415 return scale_bias_unflatten_output(
416 flat_output,
417 scales,
418 bias,
419 input_sizes
420 );
421}
422
423torch::Tensor code2x8_dequant(
424 const torch::Tensor& codes,

Callers

nothing calls this directly

Calls 3

check_use_bfloat16Function · 0.85
code2x8_matvecFunction · 0.85

Tested by

no test coverage detected