rdovae

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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).

View Source
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

func LoadDecoder(blob *dnnblob.Blob) (*Decoder, error)

LoadDecoder binds a validated libopus-style DRED decoder blob into typed Go RDOVAE decoder layers.

func (*Decoder) DecodeAll

func (m *Decoder) DecodeAll(dst, state, latents []float32, nbLatents int) int

DecodeAll mirrors libopus DRED_rdovae_decode_all() and writes the retained feature frames into dst. It returns the number of floats written.

func (*Decoder) DecodeAllWithProcessor

func (m *Decoder) DecodeAllWithProcessor(processor *Processor, dst, state, latents []float32, nbLatents int) int

DecodeAllWithProcessor mirrors libopus DRED_rdovae_decode_all() and reuses the caller-owned processor state/scratch when provided.

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

type Int8Tensor = dnnblob.Int8View

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

type IntTensor = dnnblob.Int32View

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.

type Processor

type Processor struct {
	// contains filtered or unexported fields
}

Processor owns reusable DRED decoder runtime state and scratch so callers can keep DecodeAll on an explicit zero-allocation path across packets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL