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

Function code1x8_matmat

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

Source from the content-addressed store, hash-verified

550}
551
552torch::Tensor code1x8_matmat(
553 const torch::Tensor& input,
554 const torch::Tensor& codes,
555 const torch::Tensor& codebooks,
556 const torch::Tensor& scales,
557 const std::optional<torch::Tensor>& bias
558) {
559 bool use_bfloat16 = check_use_bfloat16(input);
560 auto input_sizes = input.sizes();
561 auto out_features = codes.size(0) * codebooks.size(2);
562 auto flat_input = input.reshape({-1, input.size(-1)});
563 auto flat_output = torch::empty({flat_input.size(0), out_features},
564 torch::TensorOptions()
565 .dtype(input.dtype())
566 .device(input.device())
567 );
568
569 for (int i = 0; i < flat_input.size(0); ++i) {
570 auto input_vec = flat_input.index({i});
571 auto output_vec = flat_output.index({i});
572 code1x8_matvec(
573 codes.squeeze(2),
574 input_vec,
575 output_vec,
576 codebooks,
577 use_bfloat16
578 );
579 }
580 return scale_bias_unflatten_output(
581 flat_output,
582 scales,
583 bias,
584 input_sizes
585 );
586}
587
588torch::Tensor code1x8_dequant(
589 const torch::Tensor& codes,

Callers

nothing calls this directly

Calls 3

check_use_bfloat16Function · 0.85
code1x8_matvecFunction · 0.85

Tested by

no test coverage detected