opus1 0.2.1

Pure-Rust implementation of the Opus audio codec (RFC 6716), following libopus 1.x
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
//! LACE, the speech enhancer of SILK at decoder complexity 6: its layers and
//! the constants of its C header.
//!
//! Generated by `tools/dnn-gen` from libopus 1.6.1 `dnn/lace_data.h` and
//! `dnn/lace_data.c` (`init_lacelayers`). Do not edit: change the generator and
//! run it again (`tools/dnn-gen/README.md`).

// The float constants keep every digit of the C header.
#![allow(clippy::excessive_precision)]

use crate::Error;
use super::{Layer, LayerSpec, LinearSpec};
use crate::dnn::nnet::LinearLayer;
use crate::dnn::weights::WeightList;

/// The file of this model's weights in `dnn-weights/`.
pub const BLOB_FILE: &str = "lace.bin";

// The constants of `dnn/lace_data.h`, in the same order.

/// `LACE_PREEMPH`, `0.85f` in C.
pub const LACE_PREEMPH: f32 = 0.85;

/// `LACE_FRAME_SIZE`.
pub const LACE_FRAME_SIZE: usize = 80;

/// `LACE_OVERLAP_SIZE`.
pub const LACE_OVERLAP_SIZE: usize = 40;

/// `LACE_NUM_FEATURES`.
pub const LACE_NUM_FEATURES: usize = 93;

/// `LACE_PITCH_MAX`.
pub const LACE_PITCH_MAX: usize = 300;

/// `LACE_PITCH_EMBEDDING_DIM`.
pub const LACE_PITCH_EMBEDDING_DIM: usize = 64;

/// `LACE_NUMBITS_RANGE_LOW`.
pub const LACE_NUMBITS_RANGE_LOW: usize = 50;

/// `LACE_NUMBITS_RANGE_HIGH`.
pub const LACE_NUMBITS_RANGE_HIGH: usize = 650;

/// `LACE_NUMBITS_EMBEDDING_DIM`.
pub const LACE_NUMBITS_EMBEDDING_DIM: usize = 8;

/// `LACE_COND_DIM`.
pub const LACE_COND_DIM: usize = 128;

/// `LACE_HIDDEN_FEATURE_DIM`.
pub const LACE_HIDDEN_FEATURE_DIM: usize = 96;

/// `LACE_NUMBITS_SCALE_0`, `1.0983514785766602f` in C.
pub const LACE_NUMBITS_SCALE_0: f32 = 1.0983514785766602;

/// `LACE_NUMBITS_SCALE_1`, `2.0509142875671387f` in C.
pub const LACE_NUMBITS_SCALE_1: f32 = 2.0509142875671387;

/// `LACE_NUMBITS_SCALE_2`, `3.5729939937591553f` in C.
pub const LACE_NUMBITS_SCALE_2: f32 = 3.5729939937591553;

/// `LACE_NUMBITS_SCALE_3`, `4.478035926818848f` in C.
pub const LACE_NUMBITS_SCALE_3: f32 = 4.478035926818848;

/// `LACE_NUMBITS_SCALE_4`, `5.926519393920898f` in C.
pub const LACE_NUMBITS_SCALE_4: f32 = 5.926519393920898;

/// `LACE_NUMBITS_SCALE_5`, `7.152282238006592f` in C.
pub const LACE_NUMBITS_SCALE_5: f32 = 7.152282238006592;

/// `LACE_NUMBITS_SCALE_6`, `8.277412414550781f` in C.
pub const LACE_NUMBITS_SCALE_6: f32 = 8.277412414550781;

/// `LACE_NUMBITS_SCALE_7`, `8.926830291748047f` in C.
pub const LACE_NUMBITS_SCALE_7: f32 = 8.926830291748047;

/// `LACE_PITCH_EMBEDDING_OUT_SIZE`.
pub const LACE_PITCH_EMBEDDING_OUT_SIZE: usize = 64;

/// `LACE_FNET_CONV1_OUT_SIZE`.
pub const LACE_FNET_CONV1_OUT_SIZE: usize = 96;

/// `LACE_FNET_CONV1_IN_SIZE`.
pub const LACE_FNET_CONV1_IN_SIZE: usize = 173;

/// `LACE_FNET_CONV1_STATE_SIZE`, `(173 * (0))` in C.
pub const LACE_FNET_CONV1_STATE_SIZE: usize = 0;

/// `LACE_FNET_CONV1_DELAY`.
pub const LACE_FNET_CONV1_DELAY: usize = 0;

/// `LACE_FNET_CONV2_OUT_SIZE`.
pub const LACE_FNET_CONV2_OUT_SIZE: usize = 128;

/// `LACE_FNET_CONV2_IN_SIZE`.
pub const LACE_FNET_CONV2_IN_SIZE: usize = 384;

/// `LACE_FNET_CONV2_STATE_SIZE`, `(384 * (1))` in C.
pub const LACE_FNET_CONV2_STATE_SIZE: usize = 384;

/// `LACE_FNET_CONV2_DELAY`.
pub const LACE_FNET_CONV2_DELAY: usize = 0;

/// `LACE_FNET_TCONV_KERNEL_SIZE`.
pub const LACE_FNET_TCONV_KERNEL_SIZE: usize = 4;

/// `LACE_FNET_TCONV_STRIDE`.
pub const LACE_FNET_TCONV_STRIDE: usize = 4;

/// `LACE_FNET_TCONV_IN_CHANNELS`.
pub const LACE_FNET_TCONV_IN_CHANNELS: usize = 128;

/// `LACE_FNET_TCONV_OUT_CHANNELS`.
pub const LACE_FNET_TCONV_OUT_CHANNELS: usize = 128;

/// `LACE_FNET_GRU_OUT_SIZE`.
pub const LACE_FNET_GRU_OUT_SIZE: usize = 128;

/// `LACE_FNET_GRU_STATE_SIZE`.
pub const LACE_FNET_GRU_STATE_SIZE: usize = 128;

/// `LACE_CF1_FILTER_GAIN_A`, `0.690776f` in C.
pub const LACE_CF1_FILTER_GAIN_A: f32 = 0.690776;

/// `LACE_CF1_FILTER_GAIN_B`, `0.000000f` in C.
pub const LACE_CF1_FILTER_GAIN_B: f32 = 0.000000;

/// `LACE_CF1_LOG_GAIN_LIMIT`, `1.151293f` in C.
pub const LACE_CF1_LOG_GAIN_LIMIT: f32 = 1.151293;

/// `LACE_CF1_KERNEL_SIZE`.
pub const LACE_CF1_KERNEL_SIZE: usize = 16;

/// `LACE_CF1_LEFT_PADDING`.
pub const LACE_CF1_LEFT_PADDING: usize = 8;

/// `LACE_CF1_FRAME_SIZE`.
pub const LACE_CF1_FRAME_SIZE: usize = 80;

/// `LACE_CF1_OVERLAP_SIZE`.
pub const LACE_CF1_OVERLAP_SIZE: usize = 40;

/// `LACE_CF1_IN_CHANNELS`.
pub const LACE_CF1_IN_CHANNELS: usize = 1;

/// `LACE_CF1_OUT_CHANNELS`.
pub const LACE_CF1_OUT_CHANNELS: usize = 1;

/// `LACE_CF1_NORM_P`.
pub const LACE_CF1_NORM_P: usize = 2;

/// `LACE_CF1_FEATURE_DIM`.
pub const LACE_CF1_FEATURE_DIM: usize = 128;

/// `LACE_CF1_MAX_LAG`.
pub const LACE_CF1_MAX_LAG: usize = 301;

/// `LACE_CF1_KERNEL_OUT_SIZE`.
pub const LACE_CF1_KERNEL_OUT_SIZE: usize = 16;

/// `LACE_CF1_GAIN_OUT_SIZE`.
pub const LACE_CF1_GAIN_OUT_SIZE: usize = 1;

/// `LACE_CF1_GLOBAL_GAIN_OUT_SIZE`.
pub const LACE_CF1_GLOBAL_GAIN_OUT_SIZE: usize = 1;

/// `LACE_CF2_FILTER_GAIN_A`, `0.690776f` in C.
pub const LACE_CF2_FILTER_GAIN_A: f32 = 0.690776;

/// `LACE_CF2_FILTER_GAIN_B`, `0.000000f` in C.
pub const LACE_CF2_FILTER_GAIN_B: f32 = 0.000000;

/// `LACE_CF2_LOG_GAIN_LIMIT`, `1.151293f` in C.
pub const LACE_CF2_LOG_GAIN_LIMIT: f32 = 1.151293;

/// `LACE_CF2_KERNEL_SIZE`.
pub const LACE_CF2_KERNEL_SIZE: usize = 16;

/// `LACE_CF2_LEFT_PADDING`.
pub const LACE_CF2_LEFT_PADDING: usize = 8;

/// `LACE_CF2_FRAME_SIZE`.
pub const LACE_CF2_FRAME_SIZE: usize = 80;

/// `LACE_CF2_OVERLAP_SIZE`.
pub const LACE_CF2_OVERLAP_SIZE: usize = 40;

/// `LACE_CF2_IN_CHANNELS`.
pub const LACE_CF2_IN_CHANNELS: usize = 1;

/// `LACE_CF2_OUT_CHANNELS`.
pub const LACE_CF2_OUT_CHANNELS: usize = 1;

/// `LACE_CF2_NORM_P`.
pub const LACE_CF2_NORM_P: usize = 2;

/// `LACE_CF2_FEATURE_DIM`.
pub const LACE_CF2_FEATURE_DIM: usize = 128;

/// `LACE_CF2_MAX_LAG`.
pub const LACE_CF2_MAX_LAG: usize = 301;

/// `LACE_CF2_KERNEL_OUT_SIZE`.
pub const LACE_CF2_KERNEL_OUT_SIZE: usize = 16;

/// `LACE_CF2_GAIN_OUT_SIZE`.
pub const LACE_CF2_GAIN_OUT_SIZE: usize = 1;

/// `LACE_CF2_GLOBAL_GAIN_OUT_SIZE`.
pub const LACE_CF2_GLOBAL_GAIN_OUT_SIZE: usize = 1;

/// `LACE_AF1_FILTER_GAIN_A`, `1.381551f` in C.
pub const LACE_AF1_FILTER_GAIN_A: f32 = 1.381551;

/// `LACE_AF1_FILTER_GAIN_B`, `0.000000f` in C.
pub const LACE_AF1_FILTER_GAIN_B: f32 = 0.000000;

/// `LACE_AF1_SHAPE_GAIN`, `1.000000f` in C.
pub const LACE_AF1_SHAPE_GAIN: f32 = 1.000000;

/// `LACE_AF1_KERNEL_SIZE`.
pub const LACE_AF1_KERNEL_SIZE: usize = 16;

/// `LACE_AF1_FRAME_SIZE`.
pub const LACE_AF1_FRAME_SIZE: usize = 80;

/// `LACE_AF1_LEFT_PADDING`.
pub const LACE_AF1_LEFT_PADDING: usize = 15;

/// `LACE_AF1_OVERLAP_SIZE`.
pub const LACE_AF1_OVERLAP_SIZE: usize = 40;

/// `LACE_AF1_IN_CHANNELS`.
pub const LACE_AF1_IN_CHANNELS: usize = 1;

/// `LACE_AF1_OUT_CHANNELS`.
pub const LACE_AF1_OUT_CHANNELS: usize = 1;

/// `LACE_AF1_NORM_P`.
pub const LACE_AF1_NORM_P: usize = 2;

/// `LACE_AF1_FEATURE_DIM`.
pub const LACE_AF1_FEATURE_DIM: usize = 128;

/// `LACE_AF1_KERNEL_OUT_SIZE`.
pub const LACE_AF1_KERNEL_OUT_SIZE: usize = 16;

/// `LACE_AF1_GAIN_OUT_SIZE`.
pub const LACE_AF1_GAIN_OUT_SIZE: usize = 1;

/// The layers in the order of `init_lacelayers`: the arrays that each one
/// reads, and its shape. The names are the array names of the blob.
pub const LAYERS: [LayerSpec; 14] = [
    LayerSpec::Linear(LinearSpec {
        name: "lace_pitch_embedding",
        bias: Some("lace_pitch_embedding_bias"),
        subias: None,
        weights: None,
        float_weights: Some("lace_pitch_embedding_weights_float"),
        weights_idx: None,
        diag: None,
        scale: None,
        nb_inputs: 301,
        nb_outputs: 64,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_fnet_conv1",
        bias: Some("lace_fnet_conv1_bias"),
        subias: None,
        weights: None,
        float_weights: Some("lace_fnet_conv1_weights_float"),
        weights_idx: None,
        diag: None,
        scale: None,
        nb_inputs: 173,
        nb_outputs: 96,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_fnet_conv2",
        bias: Some("lace_fnet_conv2_bias"),
        subias: Some("lace_fnet_conv2_subias"),
        weights: Some("lace_fnet_conv2_weights_int8"),
        float_weights: Some("lace_fnet_conv2_weights_float"),
        weights_idx: None,
        diag: None,
        scale: Some("lace_fnet_conv2_scale"),
        nb_inputs: 768,
        nb_outputs: 128,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_fnet_tconv",
        bias: Some("lace_fnet_tconv_bias"),
        subias: Some("lace_fnet_tconv_subias"),
        weights: Some("lace_fnet_tconv_weights_int8"),
        float_weights: Some("lace_fnet_tconv_weights_float"),
        weights_idx: None,
        diag: None,
        scale: Some("lace_fnet_tconv_scale"),
        nb_inputs: 128,
        nb_outputs: 512,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_fnet_gru_input",
        bias: Some("lace_fnet_gru_input_bias"),
        subias: Some("lace_fnet_gru_input_subias"),
        weights: Some("lace_fnet_gru_input_weights_int8"),
        float_weights: Some("lace_fnet_gru_input_weights_float"),
        weights_idx: None,
        diag: None,
        scale: Some("lace_fnet_gru_input_scale"),
        nb_inputs: 128,
        nb_outputs: 384,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_fnet_gru_recurrent",
        bias: Some("lace_fnet_gru_recurrent_bias"),
        subias: Some("lace_fnet_gru_recurrent_subias"),
        weights: Some("lace_fnet_gru_recurrent_weights_int8"),
        float_weights: Some("lace_fnet_gru_recurrent_weights_float"),
        weights_idx: None,
        diag: None,
        scale: Some("lace_fnet_gru_recurrent_scale"),
        nb_inputs: 128,
        nb_outputs: 384,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_cf1_kernel",
        bias: Some("lace_cf1_kernel_bias"),
        subias: Some("lace_cf1_kernel_subias"),
        weights: Some("lace_cf1_kernel_weights_int8"),
        float_weights: Some("lace_cf1_kernel_weights_float"),
        weights_idx: None,
        diag: None,
        scale: Some("lace_cf1_kernel_scale"),
        nb_inputs: 128,
        nb_outputs: 16,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_cf1_gain",
        bias: Some("lace_cf1_gain_bias"),
        subias: None,
        weights: None,
        float_weights: Some("lace_cf1_gain_weights_float"),
        weights_idx: None,
        diag: None,
        scale: None,
        nb_inputs: 128,
        nb_outputs: 1,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_cf1_global_gain",
        bias: Some("lace_cf1_global_gain_bias"),
        subias: None,
        weights: None,
        float_weights: Some("lace_cf1_global_gain_weights_float"),
        weights_idx: None,
        diag: None,
        scale: None,
        nb_inputs: 128,
        nb_outputs: 1,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_cf2_kernel",
        bias: Some("lace_cf2_kernel_bias"),
        subias: Some("lace_cf2_kernel_subias"),
        weights: Some("lace_cf2_kernel_weights_int8"),
        float_weights: Some("lace_cf2_kernel_weights_float"),
        weights_idx: None,
        diag: None,
        scale: Some("lace_cf2_kernel_scale"),
        nb_inputs: 128,
        nb_outputs: 16,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_cf2_gain",
        bias: Some("lace_cf2_gain_bias"),
        subias: None,
        weights: None,
        float_weights: Some("lace_cf2_gain_weights_float"),
        weights_idx: None,
        diag: None,
        scale: None,
        nb_inputs: 128,
        nb_outputs: 1,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_cf2_global_gain",
        bias: Some("lace_cf2_global_gain_bias"),
        subias: None,
        weights: None,
        float_weights: Some("lace_cf2_global_gain_weights_float"),
        weights_idx: None,
        diag: None,
        scale: None,
        nb_inputs: 128,
        nb_outputs: 1,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_af1_kernel",
        bias: Some("lace_af1_kernel_bias"),
        subias: Some("lace_af1_kernel_subias"),
        weights: Some("lace_af1_kernel_weights_int8"),
        float_weights: Some("lace_af1_kernel_weights_float"),
        weights_idx: None,
        diag: None,
        scale: Some("lace_af1_kernel_scale"),
        nb_inputs: 128,
        nb_outputs: 16,
    }),
    LayerSpec::Linear(LinearSpec {
        name: "lace_af1_gain",
        bias: Some("lace_af1_gain_bias"),
        subias: None,
        weights: None,
        float_weights: Some("lace_af1_gain_weights_float"),
        weights_idx: None,
        diag: None,
        scale: None,
        nb_inputs: 128,
        nb_outputs: 1,
    }),
];

/// libopus `LACELayers` (`dnn/lace_data.h`): the layers of the model, in the
/// order of the C struct. Each layer borrows its arrays from a weight list.
#[derive(Clone, Copy, Default)]
pub struct LaceLayers<'w> {
    /// `lace_pitch_embedding`: float weights, 301 inputs, 64 outputs.
    pub lace_pitch_embedding: LinearLayer<'w>,
    /// `lace_fnet_conv1`: float weights, 173 inputs, 96 outputs.
    pub lace_fnet_conv1: LinearLayer<'w>,
    /// `lace_fnet_conv2`: int8 weights, 768 inputs, 128 outputs.
    pub lace_fnet_conv2: LinearLayer<'w>,
    /// `lace_fnet_tconv`: int8 weights, 128 inputs, 512 outputs.
    pub lace_fnet_tconv: LinearLayer<'w>,
    /// `lace_fnet_gru_input`: int8 weights, 128 inputs, 384 outputs.
    pub lace_fnet_gru_input: LinearLayer<'w>,
    /// `lace_fnet_gru_recurrent`: int8 weights, 128 inputs, 384 outputs.
    pub lace_fnet_gru_recurrent: LinearLayer<'w>,
    /// `lace_cf1_kernel`: int8 weights, 128 inputs, 16 outputs.
    pub lace_cf1_kernel: LinearLayer<'w>,
    /// `lace_cf1_gain`: float weights, 128 inputs, 1 output.
    pub lace_cf1_gain: LinearLayer<'w>,
    /// `lace_cf1_global_gain`: float weights, 128 inputs, 1 output.
    pub lace_cf1_global_gain: LinearLayer<'w>,
    /// `lace_cf2_kernel`: int8 weights, 128 inputs, 16 outputs.
    pub lace_cf2_kernel: LinearLayer<'w>,
    /// `lace_cf2_gain`: float weights, 128 inputs, 1 output.
    pub lace_cf2_gain: LinearLayer<'w>,
    /// `lace_cf2_global_gain`: float weights, 128 inputs, 1 output.
    pub lace_cf2_global_gain: LinearLayer<'w>,
    /// `lace_af1_kernel`: int8 weights, 128 inputs, 16 outputs.
    pub lace_af1_kernel: LinearLayer<'w>,
    /// `lace_af1_gain`: float weights, 128 inputs, 1 output.
    pub lace_af1_gain: LinearLayer<'w>,
}

impl<'w> LaceLayers<'w> {
    /// libopus `init_lacelayers`: builds every layer from the arrays of `list`,
    /// in the order of `LAYERS`. Fails at the first layer whose arrays are
    /// missing, have the wrong size or are malformed; then nothing is built.
    pub fn init(list: &WeightList<'w>) -> Result<Self, Error> {
        Ok(LaceLayers {
            lace_pitch_embedding: LAYERS[0].linear(list)?,
            lace_fnet_conv1: LAYERS[1].linear(list)?,
            lace_fnet_conv2: LAYERS[2].linear(list)?,
            lace_fnet_tconv: LAYERS[3].linear(list)?,
            lace_fnet_gru_input: LAYERS[4].linear(list)?,
            lace_fnet_gru_recurrent: LAYERS[5].linear(list)?,
            lace_cf1_kernel: LAYERS[6].linear(list)?,
            lace_cf1_gain: LAYERS[7].linear(list)?,
            lace_cf1_global_gain: LAYERS[8].linear(list)?,
            lace_cf2_kernel: LAYERS[9].linear(list)?,
            lace_cf2_gain: LAYERS[10].linear(list)?,
            lace_cf2_global_gain: LAYERS[11].linear(list)?,
            lace_af1_kernel: LAYERS[12].linear(list)?,
            lace_af1_gain: LAYERS[13].linear(list)?,
        })
    }

    /// Every layer, in the order of `LAYERS`.
    pub fn layers(&self) -> [Layer<'_, 'w>; 14] {
        [
            Layer::Linear(&self.lace_pitch_embedding),
            Layer::Linear(&self.lace_fnet_conv1),
            Layer::Linear(&self.lace_fnet_conv2),
            Layer::Linear(&self.lace_fnet_tconv),
            Layer::Linear(&self.lace_fnet_gru_input),
            Layer::Linear(&self.lace_fnet_gru_recurrent),
            Layer::Linear(&self.lace_cf1_kernel),
            Layer::Linear(&self.lace_cf1_gain),
            Layer::Linear(&self.lace_cf1_global_gain),
            Layer::Linear(&self.lace_cf2_kernel),
            Layer::Linear(&self.lace_cf2_gain),
            Layer::Linear(&self.lace_cf2_global_gain),
            Layer::Linear(&self.lace_af1_kernel),
            Layer::Linear(&self.lace_af1_gain),
        ]
    }
}