Ling-3.0-tiny-RKNN / include /ling3 /quantization.h
Sariel00's picture
Publish Ling-3.0-tiny RKNN engine and model
3fd1a35 verified
Raw History Blame Contribute Delete
1.03 kB
#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