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
- func RequiredDREDDecoderRecordNames() []string
- func RequiredDecoderControlRecordNames(requireOSCEBWE bool) []string
- func RequiredEncoderControlRecordNames() []string
- type Blob
- func (b *Blob) DecoderModels() DecoderModelState
- func (b *Blob) HasRecord(name string) bool
- func (b *Blob) Record(name string) (Record, bool)
- func (b *Blob) SupportsDREDDecoder() bool
- func (b *Blob) SupportsDREDEncoder() bool
- func (b *Blob) SupportsFARGAN() bool
- func (b *Blob) SupportsOSCE() bool
- func (b *Blob) SupportsOSCEBWE() bool
- func (b *Blob) SupportsOSCELACE() bool
- func (b *Blob) SupportsOSCENoLACE() bool
- func (b *Blob) SupportsPLC() bool
- func (b *Blob) SupportsPitchDNN() bool
- func (b *Blob) ValidateDREDDecoderControl() error
- func (b *Blob) ValidateDecoderControl(requireOSCEBWE bool) error
- func (b *Blob) ValidateEncoderControl() error
- type DecoderModelState
- type Float32View
- type Int8View
- type Int32View
- type Record
Constants ¶
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 ¶
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 ¶
Blob stores a validated copy of a libopus-style weights blob and its records.
func Clone ¶
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 ¶
HasRecord reports whether the parsed blob contains a record with the given name.
func (*Blob) Record ¶
Record returns the first record with the given name, mirroring libopus find_array_entry() first-match behavior.
func (*Blob) SupportsDREDDecoder ¶
SupportsDREDDecoder reports whether the blob contains the DRED decoder model family.
func (*Blob) SupportsDREDEncoder ¶
SupportsDREDEncoder reports whether the blob contains the DRED encoder model family.
func (*Blob) SupportsFARGAN ¶
SupportsFARGAN reports whether the blob contains the FARGAN model family.
func (*Blob) SupportsOSCE ¶
SupportsOSCE reports whether the blob contains the core OSCE model families.
func (*Blob) SupportsOSCEBWE ¶
SupportsOSCEBWE reports whether the blob contains the OSCE_BWE model family.
func (*Blob) SupportsOSCELACE ¶
SupportsOSCELACE reports whether the blob contains the LACE OSCE model family.
func (*Blob) SupportsOSCENoLACE ¶
SupportsOSCENoLACE reports whether the blob contains the NoLACE OSCE model family.
func (*Blob) SupportsPLC ¶
SupportsPLC reports whether the blob contains the PLC model family.
func (*Blob) SupportsPitchDNN ¶
SupportsPitchDNN reports whether the blob contains the pitch model family libopus uses from both DRED and PLC/FARGAN control loaders.
func (*Blob) ValidateDREDDecoderControl ¶
ValidateDREDDecoderControl mirrors the standalone libopus DRED decoder model-loading path, which only requires the RDOVAE decoder family.
func (*Blob) ValidateDecoderControl ¶
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 ¶
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) 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 ¶
Int8ViewFromBytes returns a zero-copy int8 view over raw record bytes, validating only the byte size.
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 ¶
Int32ViewFromBytes returns a zero-copy int32 view over raw record bytes, validating only the byte size and alignment.
type Record ¶
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.