10 const float *input,
size_t input_elements,
size_t input_stride,
11 const float *weight,
size_t weight_elements,
12 const float *bias,
size_t bias_elements,
13 float *output,
size_t output_elements,
size_t output_stride,
14 float *scratch,
size_t scratch_elements,
15 size_t channels,
size_t input_frames,
size_t kernel_size,
16 size_t stride,
size_t output_frames) {
17 size_t input_span, output_span, weight_count, staged;
18 if (!channels || !input_frames || !kernel_size || !stride || !output_frames ||
19 input_frames < kernel_size ||
20 (input_frames - kernel_size) / stride + 1 != output_frames ||
21 channels > SIZE_MAX / kernel_size ||
22 channels > SIZE_MAX / output_frames)
24 weight_count = channels * kernel_size;
25 staged = channels * output_frames;
26 if (!
ck_checked_span(channels, input_frames, input_stride, &input_span) ||
27 !
ck_checked_span(channels, output_frames, output_stride, &output_span) ||
28 weight_count > SIZE_MAX /
sizeof(
float) ||
29 staged > SIZE_MAX /
sizeof(
float))
31 if (input_elements < input_span || weight_elements < weight_count ||
32 bias_elements < channels || output_elements < output_span ||
33 scratch_elements < staged)
51 for (
size_t c = 0; c < channels; ++c)
54 for (
size_t c = 0; c < channels; ++c) {
55 for (
size_t t = 0; t < output_frames; ++t) {
57 for (
size_t k = 0; k < kernel_size; ++k)
58 sum = fmaf(input[c * input_stride + t * stride + k],
59 weight[c * kernel_size + k], sum);
60 scratch[c * output_frames + t] = sum;
64 for (
size_t c = 0; c < channels; ++c)
65 memcpy(output + c * output_stride, scratch + c * output_frames,
66 output_frames *
sizeof(
float));
int audio_conv1d_depthwise_channel_major_f32_checked(const float *input, size_t input_elements, size_t input_stride, const float *weight, size_t weight_elements, const float *bias, size_t bias_elements, float *output, size_t output_elements, size_t output_stride, float *scratch, size_t scratch_elements, size_t channels, size_t input_frames, size_t kernel_size, size_t stride, size_t output_frames)