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

Function add_bias_bct

src/framework/modules/streaming_conv_modules.cpp:43–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41int64_t depthwise_conv1d_output_frames(const DepthwiseConv1dConfig & config, int64_t input_frames) {
42 return (input_frames + 2 * config.padding - config.dilation * (config.kernel_size - 1) - 1) / config.stride + 1;
43}
44
45core::TensorValue add_bias_bct(
46 core::ModuleBuildContext & ctx,
47 const core::TensorValue & output,
48 int64_t channels,
49 const std::optional<core::TensorValue> & bias) {
50 if (!bias.has_value()) {
51 return output;
52 }
53 auto output_contiguous = tensor_layout::ensure_contiguous_layout_if_needed(ctx, output);
54 auto bias_view = core::reshape_tensor(ctx, *bias, core::TensorShape::from_dims({1, channels, 1}));
55 auto repeated = core::wrap_tensor(ggml_repeat(ctx.ggml, bias_view.tensor, output_contiguous.tensor), output.shape, GGML_TYPE_F32);
56 return core::wrap_tensor(ggml_add(ctx.ggml, output_contiguous.tensor, repeated.tensor), output.shape, GGML_TYPE_F32);
57}
58

Callers 1

buildMethod · 0.85

Calls 5

reshape_tensorFunction · 0.85
wrap_tensorFunction · 0.85
ggml_repeatFunction · 0.85
ggml_addFunction · 0.85

Tested by

no test coverage detected