dnnblob

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: BSD-3-Clause Imports: 6 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 dnnblob parses and validates the libopus USE_WEIGHTS_FILE neural weights blob and exposes typed views over its records.

A blob is the on-disk WeightArray container libopus loads with parse_weights() (dnn/parse_lpcnet_weights.c): a sequence of named records, each carrying a type tag and a payload of float32, int32 or int8 weights. The DRED, OSCE and LPCNet model loaders bind their layers from these records, so this package mirrors the libopus blob format and record types exactly.

Index

Constants

View Source
const (
	TypeFloat   int32 = 0
	TypeInt     int32 = 1
	TypeQWeight int32 = 2
	TypeInt8    int32 = 3
)

Record type tags, matching the libopus WeightArray type field (dnn/nnet.h WEIGHT_TYPE_*): float32, int32, quantized weights and int8.

Variables

This section is empty.

Functions

func RequiredDREDDecoderRecordNames

func RequiredDREDDecoderRecordNames() []string

RequiredDREDDecoderRecordNames returns a read-only view of the loader-derived record names for the standalone libopus DRED decoder model family.

func RequiredDecoderControlRecordNames

func RequiredDecoderControlRecordNames(requireOSCEBWE bool) []string

RequiredDecoderControlRecordNames returns a read-only view of the loader-derived record names the default-build libopus main decoder path expects from OPUS_SET_DNN_BLOB. When requireOSCEBWE is true, the returned view also includes the optional OSCE and OSCE_BWE families.

func RequiredEncoderControlRecordNames

func RequiredEncoderControlRecordNames() []string

RequiredEncoderControlRecordNames returns a read-only view of the loader-derived record names the libopus encoder path expects from OPUS_SET_DNN_BLOB.

Types

type Blob

type Blob struct {
	Raw     []byte
	Records []Record
}

Blob stores a validated copy of a libopus-style weights blob and its records.

func Clone

func Clone(data []byte) (*Blob, error)

Clone validates data using libopus parse_weights-style framing rules and returns a persistent copy whose record slices point into the copied buffer.

func (*Blob) DecoderModels

func (b *Blob) DecoderModels() DecoderModelState

DecoderModels reports which decoder-side model families are available from the retained blob.

func (*Blob) HasRecord

func (b *Blob) HasRecord(name string) bool

HasRecord reports whether the parsed blob contains a record with the given name.

func (*Blob) Record

func (b *Blob) Record(name string) (Record, bool)

Record returns the first record with the given name, mirroring libopus find_array_entry() first-match behavior.

func (*Blob) SupportsDREDDecoder

func (b *Blob) SupportsDREDDecoder() bool

SupportsDREDDecoder reports whether the blob contains the DRED decoder model family.

func (*Blob) SupportsDREDEncoder

func (b *Blob) SupportsDREDEncoder() bool

SupportsDREDEncoder reports whether the blob contains the DRED encoder model family.

func (*Blob) SupportsFARGAN

func (b *Blob) SupportsFARGAN() bool

SupportsFARGAN reports whether the blob contains the FARGAN model family.

func (*Blob) SupportsOSCE

func (b *Blob) SupportsOSCE() bool

SupportsOSCE reports whether the blob contains the core OSCE model families.

func (*Blob) SupportsOSCEBWE

func (b *Blob) SupportsOSCEBWE() bool

SupportsOSCEBWE reports whether the blob contains the OSCE_BWE model family.

func (*Blob) SupportsOSCELACE

func (b *Blob) SupportsOSCELACE() bool

SupportsOSCELACE reports whether the blob contains the LACE OSCE model family.

func (*Blob) SupportsOSCENoLACE

func (b *Blob) SupportsOSCENoLACE() bool

SupportsOSCENoLACE reports whether the blob contains the NoLACE OSCE model family.

func (*Blob) SupportsPLC

func (b *Blob) SupportsPLC() bool

SupportsPLC reports whether the blob contains the PLC model family.

func (*Blob) SupportsPitchDNN

func (b *Blob) SupportsPitchDNN() bool

SupportsPitchDNN reports whether the blob contains the pitch model family libopus uses from both DRED and PLC/FARGAN control loaders.

func (*Blob) ValidateDREDDecoderControl

func (b *Blob) ValidateDREDDecoderControl() error

ValidateDREDDecoderControl mirrors the standalone libopus DRED decoder model-loading path, which only requires the RDOVAE decoder family.

func (*Blob) ValidateDecoderControl

func (b *Blob) ValidateDecoderControl(requireOSCEBWE bool) error

ValidateDecoderControl mirrors the default-build libopus decoder DNN-blob surface by requiring the core deep-PLC model families and, when requested, the optional OSCE/OSCE_BWE families.

func (*Blob) ValidateEncoderControl

func (b *Blob) ValidateEncoderControl() error

ValidateEncoderControl mirrors the libopus encoder DNN-blob surface by requiring the model families needed for DRED encoder loading.

type DecoderModelState

type DecoderModelState struct {
	PitchDNN bool
	PLC      bool
	FARGAN   bool
	DRED     bool
	OSCE     bool
	OSCEBWE  bool
}

DecoderModelState summarizes which decoder-side model families are present in a validated weights blob.

type Float32View

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

Float32View is a zero-copy typed view over a validated float32 record payload.

func Float32ViewFromBytes

func Float32ViewFromBytes(data []byte, size int32) (Float32View, error)

Float32ViewFromBytes returns a zero-copy float32 view over raw record bytes, validating only the byte size and alignment. This matches libopus's size-driven layer binding behavior.

func (Float32View) At

func (v Float32View) At(i int) float32

At returns the i-th float32 value.

func (Float32View) Empty

func (v Float32View) Empty() bool

Empty reports whether the view is empty.

func (Float32View) Fill

func (v Float32View) Fill(dst []float32) int

Fill copies the view into dst and returns the number of values written.

func (Float32View) Len

func (v Float32View) Len() int

Len reports the number of float32 values in the view.

type Int8View

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

Int8View is a zero-copy typed view over a validated int8 record payload.

func Int8ViewFromBytes

func Int8ViewFromBytes(data []byte, size int32) (Int8View, error)

Int8ViewFromBytes returns a zero-copy int8 view over raw record bytes, validating only the byte size.

func (Int8View) At

func (v Int8View) At(i int) int8

At returns the i-th int8 value.

func (Int8View) Empty

func (v Int8View) Empty() bool

Empty reports whether the view is empty.

func (Int8View) Fill

func (v Int8View) Fill(dst []int8) int

Fill copies the view into dst and returns the number of values written.

func (Int8View) Len

func (v Int8View) Len() int

Len reports the number of int8 values in the view.

type Int32View

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

Int32View is a zero-copy typed view over a validated int32 record payload.

func Int32ViewFromBytes

func Int32ViewFromBytes(data []byte, size int32) (Int32View, error)

Int32ViewFromBytes returns a zero-copy int32 view over raw record bytes, validating only the byte size and alignment.

func (Int32View) At

func (v Int32View) At(i int) int32

At returns the i-th int32 value.

func (Int32View) Empty

func (v Int32View) Empty() bool

Empty reports whether the view is empty.

func (Int32View) Fill

func (v Int32View) Fill(dst []int32) int

Fill copies the view into dst and returns the number of values written.

func (Int32View) Len

func (v Int32View) Len() int

Len reports the number of int32 values in the view.

type Record

type Record struct {
	Name string
	Type int32
	Size int32
	Data []byte
}

Record mirrors one libopus WeightArray entry parsed from a weights blob.

func (Record) Float32View

func (r Record) Float32View() (Float32View, error)

Float32View returns a zero-copy float32 view over the record payload.

func (Record) Int8View

func (r Record) Int8View() (Int8View, error)

Int8View returns a zero-copy int8 view over the record payload.

func (Record) Int32View

func (r Record) Int32View() (Int32View, error)

Int32View returns a zero-copy int32 view over the record payload.

Jump to

Keyboard shortcuts

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