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

Function calc_subsampled_lengths

src/framework/modules/conformer_modules.cpp:21–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21core::TensorValue calc_subsampled_lengths(
22 core::ModuleBuildContext & ctx,
23 const core::TensorValue & lengths,
24 int64_t total_padding,
25 int64_t kernel_size,
26 int layers,
27 int stride) {
28 auto value = core::wrap_tensor(ggml_cast(ctx.ggml, lengths.tensor, GGML_TYPE_F32), lengths.shape, GGML_TYPE_F32);
29 for (int i = 0; i < layers; ++i) {
30 auto ones = core::wrap_tensor(ggml_div(ctx.ggml, value.tensor, value.tensor), value.shape, GGML_TYPE_F32);
31 auto add_pad = core::wrap_tensor(
32 ggml_scale(ctx.ggml, ones.tensor, static_cast<float>(total_padding - kernel_size)),
33 value.shape,
34 GGML_TYPE_F32);
35 auto one = core::wrap_tensor(ggml_scale(ctx.ggml, ones.tensor, 1.0f), value.shape, GGML_TYPE_F32);
36 auto stride_value = core::wrap_tensor(
37 ggml_scale(ctx.ggml, ones.tensor, static_cast<float>(stride)),
38 value.shape,
39 GGML_TYPE_F32);
40 value = core::wrap_tensor(ggml_add(ctx.ggml, value.tensor, add_pad.tensor), value.shape, GGML_TYPE_F32);
41 value = core::wrap_tensor(ggml_div(ctx.ggml, value.tensor, stride_value.tensor), value.shape, GGML_TYPE_F32);
42 value = core::wrap_tensor(ggml_add(ctx.ggml, value.tensor, one.tensor), value.shape, GGML_TYPE_F32);
43 value = core::wrap_tensor(ggml_floor(ctx.ggml, value.tensor), value.shape, GGML_TYPE_F32);
44 }
45 return core::wrap_tensor(ggml_cast(ctx.ggml, value.tensor, GGML_TYPE_I32), lengths.shape, GGML_TYPE_I32);
46}
47
48core::TensorValue build_time_mask_4d(
49 core::ModuleBuildContext & ctx,

Callers 1

buildMethod · 0.85

Calls 6

wrap_tensorFunction · 0.85
ggml_castFunction · 0.85
ggml_divFunction · 0.85
ggml_scaleFunction · 0.85
ggml_addFunction · 0.85
ggml_floorFunction · 0.85

Tested by

no test coverage detected