-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdecoder_dred_test_helpers_test.go
More file actions
47 lines (41 loc) · 1.12 KB
/
Copy pathdecoder_dred_test_helpers_test.go
File metadata and controls
47 lines (41 loc) · 1.12 KB
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
//go:build gopus_dred || gopus_osce
package gopus
import (
"math"
"testing"
)
func requireDecoderDREDState(t testing.TB, dec *Decoder) *decoderDREDState {
t.Helper()
if dec == nil {
t.Fatal("decoder is nil")
}
s := dec.dredState()
if s == nil {
t.Fatal("decoder DRED sidecar is nil")
}
return s
}
func assertDecoderDREDRuntimeLoadedForTest(t testing.TB, dec *Decoder, label string) {
t.Helper()
state := requireDecoderDREDState(t, dec)
if !state.dredAnalysis.Loaded() || !state.dredPredictor.Loaded() || !state.dredFARGAN.Loaded() {
t.Fatalf("decoder runtime models not loaded after %s", label)
}
}
func setDecoderComplexityForLibopusDREDParityTest(t testing.TB, dec *Decoder) {
t.Helper()
if err := dec.SetComplexity(10); err != nil {
t.Fatalf("SetComplexity(10) error: %v", err)
}
}
func assertFloat32BitsEqual(t *testing.T, got, want []float32, label string) {
t.Helper()
if len(got) != len(want) {
t.Fatalf("%s len=%d want %d", label, len(got), len(want))
}
for i := range got {
if math.Float32bits(got[i]) != math.Float32bits(want[i]) {
t.Fatalf("%s[%d]=%g want %g", label, i, got[i], want[i])
}
}
}