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

Function build_timestep_embedding

src/models/vibevoice/diffusion_head.cpp:141–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141core::TensorValue build_timestep_embedding(
142 core::ModuleBuildContext & ctx,
143 const core::TensorValue & timesteps,
144 const VibeVoiceDiffusionHeadWeights & weights,
145 const VibeVoiceDiffusionHeadConfig & config) {
146 core::validate_rank_between(timesteps, 1, 1, "timesteps");
147 const int64_t batch = timesteps.shape.dims[0];
148 auto freqs = core::reshape_tensor(ctx, weights.time_freqs, core::TensorShape::from_dims({1, kTimestepFrequencyEmbeddingSize / 2}));
149 freqs = modules::RepeatModule({core::TensorShape::from_dims({batch, kTimestepFrequencyEmbeddingSize / 2})}).build(ctx, freqs);
150 auto expanded_time = core::reshape_tensor(ctx, timesteps, core::TensorShape::from_dims({batch, 1}));
151 expanded_time = modules::RepeatModule({core::TensorShape::from_dims({batch, kTimestepFrequencyEmbeddingSize / 2})}).build(ctx, expanded_time);
152 auto args = modules::MulModule{}.build(ctx, expanded_time, freqs);
153 auto cos_part = core::wrap_tensor(ggml_cos(ctx.ggml, args.tensor), args.shape, GGML_TYPE_F32);
154 auto sin_part = core::wrap_tensor(ggml_sin(ctx.ggml, args.tensor), args.shape, GGML_TYPE_F32);
155 auto embedding = modules::ConcatModule({1}).build(ctx, cos_part, sin_part);
156 auto hidden = modules::LinearModule(
157 binding::linear_config(kTimestepFrequencyEmbeddingSize, config.hidden_size, false))
158 .build(ctx, embedding, weights.timestep_fc1);
159 hidden = modules::SiluModule{}.build(ctx, hidden);
160 return modules::LinearModule(
161 binding::linear_config(config.hidden_size, config.hidden_size, false))
162 .build(ctx, hidden, weights.timestep_fc2);
163}
164
165core::TensorValue build_swiglu(
166 core::ModuleBuildContext & ctx,

Callers 1

Calls 10

validate_rank_betweenFunction · 0.85
reshape_tensorFunction · 0.85
RepeatModuleClass · 0.85
wrap_tensorFunction · 0.85
ggml_cosFunction · 0.85
ggml_sinFunction · 0.85
ConcatModuleClass · 0.85
LinearModuleClass · 0.85
linear_configFunction · 0.85
buildMethod · 0.45

Tested by

no test coverage detected