MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / test_float32_matches_torch_cuda

Function test_float32_matches_torch_cuda

tests/unittests/test_torch_random.cpp:33–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33void test_float32_matches_torch_cuda() {
34 const std::vector<float> expected_seed_1234 = {
35 -1.61649048F, 0.56845516F, -0.510224819F, -0.911339402F,
36 -1.15551639F, -0.22615087F, -1.2891326F, 1.065382F,
37 -0.7166605F, -0.533334374F, 0.207757875F, -0.979843318F,
38 0.744693458F, -0.239484429F, 0.27371496F, 0.092008315F,
39 };
40 const auto actual = engine::sampling::generate_torch_cuda_randn(
41 expected_seed_1234.size(),
42 1234,
43 engine::sampling::TorchRandnPrecision::Float32);
44 require_vector_close(actual, expected_seed_1234, 2.0e-6F, "float32 torch_cuda_randn");
45
46 const auto extended = engine::sampling::generate_torch_cuda_randn(
47 300,
48 1234,
49 engine::sampling::TorchRandnPrecision::Float32);
50 const std::vector<std::pair<size_t, float>> expected_positions = {
51 {16, -0.803610802F},
52 {17, -1.6377064F},
53 {31, -0.300402969F},
54 {32, -0.251393795F},
55 {63, -0.924830973F},
56 {64, 0.799798131F},
57 {127, -0.167921364F},
58 {128, -0.322486848F},
59 {255, -1.76037288F},
60 {256, 0.534284174F},
61 {299, -0.986868858F},
62 };
63 for (const auto & [index, expected] : expected_positions) {
64 require_close(extended[index], expected, 2.0e-6F, "float32 torch_cuda_randn high index");
65 }
66}
67
68void test_bfloat16_matches_torch_cuda() {
69 const std::vector<float> expected_seed_5678 = {

Callers 1

mainFunction · 0.85

Calls 4

require_vector_closeFunction · 0.70
require_closeFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected