amos 2f32624d3b Batch 18 (20261026-C-hwe-codegen-18): add 100 calibrated HWE code-gen tasks; pause production for rollout
100 tasks from the HWE arm-linux code-gen pool (outside the lk/man/pth
range given to batch 22), each with at least one independent
contract-edge defect and plain public docs. Claude reviewed 100/100
USABLE against current digests; no ID or source overlap with main or
batch 22. Difficulty is unmeasured.

progress.md records the wrap-up: all Codex sessions and Qwen schedulers
stopped for the user's rollout, Qwen results so far (57 HARD of 373),
and what is left on each batch branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 17:52:13 +08:00

85 lines
2.8 KiB
C++

#ifndef AQ_QUANT_HPP
#define AQ_QUANT_HPP
#include <array>
#include <cstddef>
#include <cstdint>
namespace aq {
constexpr std::size_t max_channels = 8;
enum class Status {
Ok = 0,
Index = 1,
Scale = 2,
Zero = 3,
Range = 4,
Value = 5,
Layout = 6,
Shape = 7,
Buffer = 8,
NotReady = 9
};
enum class Layout { Interleaved = 0, Planar = 1, Blocked = 2 };
struct Rational {
std::int64_t num;
std::int64_t den;
};
struct Profile {
std::int64_t num;
std::int64_t den;
int zero;
int low;
int high;
};
struct Counters {
std::uint64_t quantized;
std::uint64_t dequantized;
std::uint64_t converted;
std::uint64_t clipped_low;
std::uint64_t clipped_high;
};
class Bank {
public:
Bank();
Status configure(std::size_t channel, const Profile& profile);
Status replace(std::size_t count, const Profile* profiles);
Status erase(std::size_t channel);
void reset();
Status get(std::size_t channel, Profile& output) const;
bool ready(std::size_t channel) const;
std::size_t count() const;
std::uint64_t revision() const;
Counters counters() const;
void clear_counters();
Status quantize(std::size_t channel, Rational input, int& output);
Status dequantize(std::size_t channel, int input, Rational& output);
Status convert(std::size_t source, std::size_t destination, int input, int& output);
Status quantize_many(Layout layout, std::size_t channels, std::size_t frames,
std::size_t block, const Rational* input, std::size_t count,
int* output, std::size_t capacity);
Status dequantize_many(Layout layout, std::size_t channels, std::size_t frames,
std::size_t block, const int* input, std::size_t count,
Rational* output, std::size_t capacity);
private:
std::array<Profile, max_channels> profiles_;
std::array<bool, max_channels> ready_;
std::uint64_t revision_;
Counters counters_;
void record_clip(int direction, Counters& counters) const;
Status validate_shape(Layout layout, std::size_t channels, std::size_t frames,
std::size_t block, std::size_t count) const;
std::size_t channel_at(Layout layout, std::size_t channels, std::size_t frames,
std::size_t block, std::size_t index) const;
};
namespace detail {
std::int64_t gcd(std::int64_t left, std::int64_t right);
Status normalize(const Profile& input, Profile& output);
bool same(const Profile& left, const Profile& right);
bool valid(Rational value);
bool valid_code(int value);
Rational reduce(std::int64_t numerator, std::int64_t denominator);
int encode(const Profile& profile, Rational input, int& clipping);
Rational decode(const Profile& profile, int input);
}
}
#endif