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

Function build_sequence_mask

src/models/seed_vc/length_regulator.cpp:56–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54 throw std::runtime_error("Seed-VC length regulator requires non-empty token ids");
55 }
56 if (static_cast<int64_t>(token_ids.size()) != expected_count) {
57 throw std::runtime_error("Seed-VC length regulator token count mismatch");
58 }
59 for (const int32_t token : token_ids) {
60 if (token < 0 || token >= codebook_size) {
61 throw std::runtime_error("Seed-VC length regulator token id is outside the codebook");
62 }
63 }
64}
65
66std::vector<float> build_sequence_mask(
67 const std::vector<int64_t> & lengths,
68 int64_t output_tokens,
69 int64_t channels) {
70 if (output_tokens <= 0 || channels <= 0) {
71 throw std::runtime_error("Seed-VC length regulator mask dimensions must be positive");
72 }
73 std::vector<float> mask(static_cast<size_t>(lengths.size() * output_tokens * channels), 0.0F);
74 for (size_t batch = 0; batch < lengths.size(); ++batch) {
75 const int64_t valid = lengths[batch];
76 if (valid <= 0 || valid > output_tokens) {
77 throw std::runtime_error("Seed-VC length regulator output length is out of range");
78 }
79 for (int64_t token = 0; token < valid; ++token) {
80 const size_t base = (batch * static_cast<size_t>(output_tokens) + static_cast<size_t>(token)) *
81 static_cast<size_t>(channels);

Callers 2

runMethod · 0.85
runMethod · 0.85

Calls 2

sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected