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

Function apply_dcw_correction

src/models/ace_step/diffusion.cpp:908–949  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

906 if (noise_file.empty()) {
907 return gaussian_noise(count, seed);
908 }
909 auto values = io::read_f32_file(noise_file);
910 if (values.size() != count) {
911 throw std::runtime_error(
912 "ACE-Step diffusion noise file size mismatch: expected " +
913 std::to_string(count) + " floats, got " + std::to_string(values.size()));
914 }
915 return values;
916}
917
918struct NoiseSchedule {
919 std::vector<float> initial_noise;
920 std::vector<std::vector<float>> renoise_noises;
921};
922
923NoiseSchedule load_noise_schedule_or_sample(const std::string & noise_file, size_t count, uint32_t seed) {
924 NoiseSchedule schedule;
925 if (noise_file.empty()) {
926 schedule.initial_noise = gaussian_noise(count, seed);
927 return schedule;
928 }
929 auto values = io::read_f32_file(noise_file);
930 if (values.empty() || values.size() % count != 0) {
931 throw std::runtime_error(
932 "ACE-Step diffusion noise file size mismatch: expected a positive multiple of " +
933 std::to_string(count) + " floats, got " + std::to_string(values.size()));
934 }
935 const size_t chunks = values.size() / count;
936 schedule.initial_noise.assign(values.begin(), values.begin() + static_cast<std::ptrdiff_t>(count));
937 schedule.renoise_noises.reserve(chunks > 0 ? chunks - 1 : 0);
938 for (size_t chunk = 1; chunk < chunks; ++chunk) {
939 const auto begin = values.begin() + static_cast<std::ptrdiff_t>(chunk * count);
940 schedule.renoise_noises.emplace_back(begin, begin + static_cast<std::ptrdiff_t>(count));
941 }
942 return schedule;
943}
944
945} // namespace
946
947class AceStepDiffusionRuntime::Impl {
948public:
949 class CrossAttentionCacheGraph {
950 public:
951 CrossAttentionCacheGraph(
952 std::shared_ptr<const AceStepAssets> assets,

Callers 1

generate_latentsMethod · 0.85

Calls 7

dcw_is_activeFunction · 0.85
wavelet_dwt_prefixFunction · 0.85
wavelet_idwt_prefixFunction · 0.85
copyFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected