File size: 1,028 Bytes
3fd1a35 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #pragma once
#include <cstddef>
#include <cstdint>
#include <span>
namespace ling3 {
struct DynamicQuantization {
float scale = 1.0F;
std::size_t clipped = 0;
};
DynamicQuantization QuantizeSymmetricInt8(
std::span<const float> input,
std::span<std::int8_t> output) noexcept;
DynamicQuantization QuantizeSymmetricInt4(
std::span<const float> input,
std::span<std::int8_t> output) noexcept;
std::int8_t DecodeInt4LowFirst(
std::span<const std::byte> packed,
std::size_t index);
void SplitInt8ForInt4Matmul(
std::span<const std::int8_t> input,
std::span<std::int8_t> high,
std::span<std::int8_t> low);
void ReferenceW4Linear(
std::span<const std::int8_t> input,
std::span<const std::byte> packed_weights,
std::size_t output_channels,
std::span<std::int32_t> output);
void DequantizePerChannel(
std::span<const std::int32_t> input,
float input_scale,
std::span<const float> weight_scales,
std::span<float> output) noexcept;
} // namespace ling3
|