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

Function tokenizer_conv1d_bct

src/models/chatterbox/s3_tokenizer_impl.cpp:271–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269 GGML_TYPE_F32);
270}
271
272engine::core::TensorValue tokenizer_conv1d_bct(
273 engine::core::ModuleBuildContext & ctx,
274 const engine::core::TensorValue & input,
275 const S3TokenizerV2Weights::Conv1dWeights & weights) {
276 const int64_t batch = input.shape.dims[0];
277 const int64_t in_frames = input.shape.dims[2];
278 const int64_t out_frames =
279 (in_frames + 2 * weights.padding - weights.kernel) / weights.stride + 1;
280 auto output = engine::core::wrap_tensor(
281 ggml_conv_1d(
282 ctx.ggml,
283 contiguous(ctx, weights.weight_tensor).tensor,
284 contiguous(ctx, input).tensor,
285 static_cast<int>(weights.stride),
286 static_cast<int>(weights.padding),
287 1),
288 engine::core::TensorShape::from_dims({batch, weights.out_channels, out_frames}),
289 GGML_TYPE_F32);
290 const auto bias_view = engine::core::reshape_tensor(
291 ctx,
292 weights.bias_tensor,
293 engine::core::TensorShape::from_dims({1, weights.out_channels, 1}));
294 return engine::core::wrap_tensor(
295 ggml_add(ctx.ggml, output.tensor, bias_view.tensor),
296 output.shape,
297 GGML_TYPE_F32);
298}
299
300engine::core::TensorValue tokenizer_fsmn_btc(

Callers 1

Calls 5

wrap_tensorFunction · 0.85
ggml_conv_1dFunction · 0.85
reshape_tensorFunction · 0.85
ggml_addFunction · 0.85
contiguousFunction · 0.70

Tested by

no test coverage detected