Documentation
¶
Overview ¶
Package rdovae implements the libopus RDOVAE (rate-distortion-optimized variational auto-encoder) used by Deep Redundancy (DRED).
The encoder compresses 20-feature LPCNet frames into quantized latent and state vectors; the decoder reconstructs feature frames from those latents. Both the encoder (encoder_model.go / encoder_runtime.go) and decoder (model.go / runtime.go) bind their weights from a validated dnnblob.Blob and mirror libopus 1.6.1 dnn/dred_rdovae_{enc,dec}.c and dnn/dred_rdovae_*_data.c bit-for-bit, held in place by the package and decoder DRED parity tests.
Index ¶
Constants ¶
const ( NumFeatures = 20 LatentDim = 25 StateDim = 50 PaddedLatentDim = 32 PaddedStateDim = 56 NumQuantLevels = 16 MaxRNNNeurons = 64 MaxConvInputs = 128 EncMaxRNNNeurons = 128 EncMaxConvInputs = 128 DecMaxRNNNeurons = 64 MaxProcessFrames = 4 Dense1OutSize = 96 HiddenInitOutSize = 128 OutputOutSize = 4 * NumFeatures ConvDenseOutSize = 32 GRUInitOutSize = 320 GRUOutSize = 64 GRUStateSize = 64 ConvOutSize = 32 ConvInSize = 32 ConvStateSize = 32 ProcessBufferSize = Dense1OutSize + 5*GRUOutSize + 5*ConvOutSize )
RDOVAE model dimensions, copied verbatim from libopus 1.6.1 dnn/dred_rdovae_constants.h and the dred_rdovae_{enc,dec}_data layer specs. They size the dense/GRU/conv stages of both the encoder and decoder and the quantized latent/state representation (LatentDim, StateDim and their padded widths, plus NumQuantLevels quantizer entries).
const SparseBlockSize = 32
SparseBlockSize is the libopus block-sparse weight tile width (SPARSE_BLOCK_SIZE in dnn/parse_lpcnet_weights.c): block-sparse layers store nonzero weights in 32-output blocks.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct {
Dense1 LinearLayer
GLU [5]LinearLayer
HiddenInit LinearLayer
Output LinearLayer
ConvDense [5]LinearLayer
GRUInit LinearLayer
GRUInput [5]LinearLayer
GRURecur [5]LinearLayer
Conv [5]LinearLayer
}
Decoder mirrors the libopus RDOVAEDec model layout used by DRED decoding.
func LoadDecoder ¶
LoadDecoder binds a validated libopus-style DRED decoder blob into typed Go RDOVAE decoder layers.
type EncoderModel ¶
type EncoderModel struct {
Dense1 LinearLayer
ZDense LinearLayer
GDense2 LinearLayer
GDense1 LinearLayer
ConvDense [5]LinearLayer
GRUInput [5]LinearLayer
GRURecur [5]LinearLayer
Conv [5]LinearLayer
}
EncoderModel mirrors the libopus RDOVAEEnc model layout used by DRED encoding.
func LoadEncoder ¶
func LoadEncoder(blob *dnnblob.Blob) (*EncoderModel, error)
LoadEncoder binds a validated libopus-style DRED encoder blob into typed Go RDOVAE encoder layers.
func (*EncoderModel) EncodeDFrame ¶
func (m *EncoderModel) EncodeDFrame(latents, initialState, input []float32) bool
EncodeDFrame mirrors libopus dred_rdovae_encode_dframe() for one concatenated 2x20-feature DRED input frame.
func (*EncoderModel) EncodeDFrameWithProcessor ¶
func (m *EncoderModel) EncodeDFrameWithProcessor(processor *EncoderProcessor, latents, initialState, input []float32) bool
EncodeDFrameWithProcessor mirrors libopus dred_rdovae_encode_dframe() and reuses caller-owned recurrent state/scratch when provided.
type EncoderProcessor ¶
type EncoderProcessor struct {
// contains filtered or unexported fields
}
EncoderProcessor owns reusable DRED encoder runtime state and scratch so callers can keep repeated d-frame encoding on an explicit zero-allocation path.
func (*EncoderProcessor) Reset ¶
func (p *EncoderProcessor) Reset()
Reset clears the retained encoder-side RDOVAE recurrent state.
type FloatTensor ¶
type FloatTensor = dnnblob.Float32View
FloatTensor, IntTensor and Int8Tensor are convenience aliases for the dnnblob views over the float32, int32 and int8 weight records the RDOVAE runtime reads.
type Int8Tensor ¶
FloatTensor, IntTensor and Int8Tensor are convenience aliases for the dnnblob views over the float32, int32 and int8 weight records the RDOVAE runtime reads.
type IntTensor ¶
FloatTensor, IntTensor and Int8Tensor are convenience aliases for the dnnblob views over the float32, int32 and int8 weight records the RDOVAE runtime reads.
type LinearLayer ¶
type LinearLayer struct {
Bias dnnblob.Float32View
Subias dnnblob.Float32View
Weights dnnblob.Int8View
FloatWeights dnnblob.Float32View
WeightsIdx dnnblob.Int32View
Scale dnnblob.Float32View
NbInputs int
NbOutputs int
}
LinearLayer mirrors the libopus LinearLayer metadata and tensors the DRED decoder runtime depends on.
type LinearLayerSpec ¶
type LinearLayerSpec struct {
Name string
Bias string
Subias string
Weights string
FloatWeights string
WeightsIdx string
Scale string
NbInputs int
NbOutputs int
}
LinearLayerSpec mirrors one init_rdovaedec() linear_init(...) declaration.
func DecoderLayerSpecs ¶
func DecoderLayerSpecs() []LinearLayerSpec
DecoderLayerSpecs returns the libopus-shaped DRED decoder layer specs the pure-Go loader binds from a validated DNN blob. Callers must treat the returned slice as read-only.
func EncoderLayerSpecs ¶
func EncoderLayerSpecs() []LinearLayerSpec
EncoderLayerSpecs returns the libopus-shaped DRED encoder layer specs the pure-Go loader binds from a validated DNN blob. Callers must treat the returned slice as read-only.