MCPcopy Create free account
hub / github.com/Arm-Examples/ML-examples / sampler_ping_pong

Function sampler_ping_pong

kleidiai-examples/audiogen-et/app/main.cpp:132–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132static void sampler_ping_pong(float* dit_out_data, float* dit_x_tensor, size_t dit_x_in_sz, float cur_t, float next_t, size_t step_idx, size_t seed) {
133
134 for(size_t i = 0; i < dit_x_in_sz; i++) {
135 dit_out_data[i] = dit_x_tensor[i] - ( cur_t * dit_out_data[i]);
136 }
137
138 std::vector<float> rand_tensor(dit_x_in_sz);
139 fill_random_norm_dist(rand_tensor.data(), dit_x_in_sz, seed);
140
141 // x = (1-t_next) * denoised + t_next * torch.randn_like(x)
142 for(size_t i = 0; i < dit_x_in_sz; i++) {
143 dit_x_tensor[i] = ((1.0f - next_t) * dit_out_data[i]) + (next_t * rand_tensor[i]);
144 }
145}
146
147static void save_as_wav(const std::string& path, const float* left_ch, const float* right_ch, size_t buffer_sz) {
148 constexpr int32_t audio_sr = 44100;

Callers 1

mainFunction · 0.70

Calls 1

fill_random_norm_distFunction · 0.70

Tested by

no test coverage detected