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

Function make_padding_mask

src/models/stable_audio/sampler.cpp:49–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49std::vector<float> make_padding_mask(const StableAudioConfig & config, const StableAudioRequest & request, int64_t latent_size) {
50 std::vector<float> mask(static_cast<size_t>(request.batch_size * latent_size), 0.0F);
51 for (int64_t b = 0; b < request.batch_size; ++b) {
52 const float seconds = request.durations_seconds[static_cast<size_t>(b)];
53 const int64_t audio_samples = static_cast<int64_t>(seconds * static_cast<float>(config.sample_rate));
54 const int64_t raw_effective = ceil_div_i64(audio_samples, config.downsampling_ratio);
55 const int64_t headroom = static_cast<int64_t>(
56 request.duration_padding_seconds * static_cast<float>(config.sample_rate) /
57 static_cast<float>(config.downsampling_ratio));
58 const int64_t valid = std::min<int64_t>(latent_size, raw_effective + headroom);
59 for (int64_t t = 0; t < valid; ++t) {
60 mask[static_cast<size_t>(b * latent_size + t)] = 1.0F;
61 }
62 }
63 return mask;
64}
65
66float shifted_full_timestep(const StableAudioConfig & config, float t, int64_t seq_len) {
67 if (t <= 0.0F) {

Callers 4

sampleMethod · 0.85
sample_v_ddimMethod · 0.85
run_dit_modelMethod · 0.85

Calls 1

ceil_div_i64Function · 0.85

Tested by

no test coverage detected