Numerically explicit audio frontend reference kernels. More...
#include "ckernel_audio.h"#include "ck_threadpool.h"#include <math.h>#include <limits.h>#include <stddef.h>#include <stdlib.h>#include <string.h>Go to the source code of this file.
Macros | |
| #define | CK_AUDIO_PI_D 3.14159265358979323846264338327950288 |
| #define | CK_AUDIO_PI_F 3.14159265358979323846f |
Functions | |
| int | audio_conv1d_channel_major_f32 (const float *input, const float *weight, const float *bias, float *output, int input_channels, int output_channels, int input_frames, int kernel_size, int stride, int padding, int output_frames) |
| int | audio_conv2d_whc_grouped_f32 (const float *input, const float *weight, const float *bias, float *output, int input_width, int input_height, int input_channels, int output_channels, int kernel_width, int kernel_height, int stride_width, int stride_height, int padding_width, int padding_height, int groups, int output_width, int output_height) |
| int | audio_feature_normalize_per_feature_f32 (const float *input, float *output, int channels, int frames, float epsilon) |
| int | audio_glu_split_channel_major_f32 (const float *input, float *output, int channels, int frames) |
| static double | audio_hz_to_mel_slaney (double hz) |
| int | audio_log_mel_time_major_f32 (const float *power, const float *mel_filters, float *log_mel, int frames, int bins, int channels, float epsilon) |
| static double | audio_mel_to_hz_slaney (double mel) |
| int | audio_pad_or_truncate_f32 (const float *input, int input_frames, float *output, int output_frames) |
| int | audio_pcm_s16_to_mono_f32 (const int16_t *interleaved, int n_frames, int n_channels, float *mono) |
| int | audio_preemphasis_f32 (const float *input, float *output, int frames, float coefficient) |
| int | audio_relative_shift_f32 (const float *raw_scores, float *scores, int heads, int query_frames) |
| int | audio_resample_linear_f32 (const float *input, int input_frames, int input_rate, float *output, int output_frames, int output_rate) |
| int | audio_resample_windowed_sinc_f32 (const float *input, int input_frames, int input_rate, float *output, int output_frames, int output_rate, int radius) |
| int | audio_resampled_frame_count (int input_frames, int input_rate, int output_rate) |
| int | audio_stft_power_centered_window_f32 (const float *samples, int n_samples, const float *window, int window_length, const float *cos_table, const float *sin_table, int n_fft, int hop_length, int reflect_padding, float *power, int n_frames) |
| int | audio_stft_power_fft400_f32 (const float *samples, int n_samples, const float *window, const float *cos_table, const float *sin_table, int hop_length, float *power, int n_frames, float *fft_scratch) |
| static void | audio_stft_power_fft400_frame_f32 (const float *samples, int n_samples, int frame, const float *window, const float *cos_table, const float *sin_table, float *power, float *fft_scratch) |
| int | audio_stft_power_precomputed_f32 (const float *samples, int n_samples, const float *window, const float *cos_table, const float *sin_table, int n_fft, int hop_length, float *power, int n_frames) |
| int | audio_stft_precompute_tables_f32 (int n_fft, float *window, float *cos_table, float *sin_table) |
| int | audio_transpose_channel_to_token_f32 (const float *input, float *output, int channels, int frames) |
| int | audio_wav_decode_memory_pcm16_mono_f32 (const uint8_t *bytes, size_t byte_count, float *mono, int mono_capacity, CKAudioWavInfo *info) |
| int | audio_wav_decode_memory_pcm16_mono_window_f32 (const uint8_t *bytes, size_t byte_count, int start_frame, float *mono, int mono_capacity, CKAudioWavInfo *info) |
| int | audio_wav_decode_pcm16_mono_f32 (const uint8_t *bytes, size_t byte_count, const CKAudioWavInfo *info, float *mono, int mono_capacity) |
| int | audio_wav_parse_memory (const uint8_t *bytes, size_t byte_count, CKAudioWavInfo *info) |
| int | audio_whisper_log_mel_from_power_reference_f32 (const float *power, const float *mel_filters, int n_mels, int n_frames, float *log_mel) |
| int | audio_whisper_log_mel_reference_f32 (const float *samples, int n_samples, const float *mel_filters, int n_mels, float *power_scratch, float *log_mel, int n_frames) |
| int | audio_whisper_log_mel_window_wav_pcm16_f32 (const uint8_t *bytes, size_t byte_count, int start_frame, int target_sample_rate, const float *window, const float *cos_table, const float *sin_table, const float *mel_filters, int n_mels, int output_frames, float *log_mel) |
| int | audio_whisper_mel_filters_slaney_f32 (int sample_rate, int n_fft, int n_mels, float *mel_filters) |
| int | audio_whisper_stft_power_reference_f32 (const float *samples, int n_samples, float *power, int n_frames) |
| static void | ck_audio_conv1d_channel_major_f32_work (int ith, int nth, void *opaque) |
| static void | ck_audio_conv2d_whc_grouped_f32_range (int begin, int end, void *opaque) |
| static void | ck_audio_glu_split_f32_range (int begin, int end, void *opaque) |
| static void | ck_audio_relative_shift_f32_range (int begin, int end, void *opaque) |
| static uint16_t | read_u16_le (const uint8_t *p) |
| static uint32_t | read_u32_le (const uint8_t *p) |
| static int | reflect_index (int index, int length) |
Numerically explicit audio frontend reference kernels.
Definition in file audio_kernels.c.
| #define CK_AUDIO_PI_D 3.14159265358979323846264338327950288 |
Definition at line 19 of file audio_kernels.c.
| #define CK_AUDIO_PI_F 3.14159265358979323846f |
Definition at line 18 of file audio_kernels.c.
| int audio_conv1d_channel_major_f32 | ( | const float * | input, |
| const float * | weight, | ||
| const float * | bias, | ||
| float * | output, | ||
| int | input_channels, | ||
| int | output_channels, | ||
| int | input_frames, | ||
| int | kernel_size, | ||
| int | stride, | ||
| int | padding, | ||
| int | output_frames | ||
| ) |
Definition at line 902 of file audio_kernels.c.
References ck_audio_conv1d_channel_major_f32_work(), ck_threadpool_dispatch_n(), ck_threadpool_global(), and ck_threadpool_n_threads().
| int audio_conv2d_whc_grouped_f32 | ( | const float * | input, |
| const float * | weight, | ||
| const float * | bias, | ||
| float * | output, | ||
| int | input_width, | ||
| int | input_height, | ||
| int | input_channels, | ||
| int | output_channels, | ||
| int | kernel_width, | ||
| int | kernel_height, | ||
| int | stride_width, | ||
| int | stride_height, | ||
| int | padding_width, | ||
| int | padding_height, | ||
| int | groups, | ||
| int | output_width, | ||
| int | output_height | ||
| ) |
Definition at line 1025 of file audio_kernels.c.
References ck_audio_conv2d_whc_grouped_f32_range(), ck_threadpool_global(), ck_threadpool_n_threads(), and ck_threadpool_parallel_for_n().
| int audio_feature_normalize_per_feature_f32 | ( | const float * | input, |
| float * | output, | ||
| int | channels, | ||
| int | frames, | ||
| float | epsilon | ||
| ) |
Definition at line 328 of file audio_kernels.c.
| int audio_glu_split_channel_major_f32 | ( | const float * | input, |
| float * | output, | ||
| int | channels, | ||
| int | frames | ||
| ) |
Definition at line 1115 of file audio_kernels.c.
References ck_audio_glu_split_f32_range(), ck_threadpool_global(), ck_threadpool_n_threads(), and ck_threadpool_parallel_for_n().
|
static |
Definition at line 399 of file audio_kernels.c.
Referenced by audio_whisper_mel_filters_slaney_f32().
| int audio_log_mel_time_major_f32 | ( | const float * | power, |
| const float * | mel_filters, | ||
| float * | log_mel, | ||
| int | frames, | ||
| int | bins, | ||
| int | channels, | ||
| float | epsilon | ||
| ) |
Definition at line 553 of file audio_kernels.c.
|
static |
Definition at line 407 of file audio_kernels.c.
Referenced by audio_whisper_mel_filters_slaney_f32().
| int audio_pad_or_truncate_f32 | ( | const float * | input, |
| int | input_frames, | ||
| float * | output, | ||
| int | output_frames | ||
| ) |
Definition at line 280 of file audio_kernels.c.
| int audio_pcm_s16_to_mono_f32 | ( | const int16_t * | interleaved, |
| int | n_frames, | ||
| int | n_channels, | ||
| float * | mono | ||
| ) |
Definition at line 176 of file audio_kernels.c.
| int audio_preemphasis_f32 | ( | const float * | input, |
| float * | output, | ||
| int | frames, | ||
| float | coefficient | ||
| ) |
Definition at line 303 of file audio_kernels.c.
| int audio_relative_shift_f32 | ( | const float * | raw_scores, |
| float * | scores, | ||
| int | heads, | ||
| int | query_frames | ||
| ) |
Definition at line 1173 of file audio_kernels.c.
References ck_audio_relative_shift_f32_range(), ck_threadpool_global(), ck_threadpool_n_threads(), and ck_threadpool_parallel_for_n().
| int audio_resample_linear_f32 | ( | const float * | input, |
| int | input_frames, | ||
| int | input_rate, | ||
| float * | output, | ||
| int | output_frames, | ||
| int | output_rate | ||
| ) |
Definition at line 210 of file audio_kernels.c.
References audio_resampled_frame_count(), left, and right.
| int audio_resample_windowed_sinc_f32 | ( | const float * | input, |
| int | input_frames, | ||
| int | input_rate, | ||
| float * | output, | ||
| int | output_frames, | ||
| int | output_rate, | ||
| int | radius | ||
| ) |
Definition at line 235 of file audio_kernels.c.
References audio_resampled_frame_count(), and CK_AUDIO_PI_D.
| int audio_resampled_frame_count | ( | int | input_frames, |
| int | input_rate, | ||
| int | output_rate | ||
| ) |
Definition at line 199 of file audio_kernels.c.
Referenced by audio_resample_linear_f32(), and audio_resample_windowed_sinc_f32().
| int audio_stft_power_centered_window_f32 | ( | const float * | samples, |
| int | n_samples, | ||
| const float * | window, | ||
| int | window_length, | ||
| const float * | cos_table, | ||
| const float * | sin_table, | ||
| int | n_fft, | ||
| int | hop_length, | ||
| int | reflect_padding, | ||
| float * | power, | ||
| int | n_frames | ||
| ) |
Definition at line 498 of file audio_kernels.c.
References reflect_index().
| int audio_stft_power_fft400_f32 | ( | const float * | samples, |
| int | n_samples, | ||
| const float * | window, | ||
| const float * | cos_table, | ||
| const float * | sin_table, | ||
| int | hop_length, | ||
| float * | power, | ||
| int | n_frames, | ||
| float * | fft_scratch | ||
| ) |
Definition at line 593 of file audio_kernels.c.
References audio_stft_power_fft400_frame_f32(), CK_AUDIO_WHISPER_HOP_LENGTH, CK_AUDIO_WHISPER_N_FFT, and CK_AUDIO_WHISPER_POWER_BINS.
|
static |
Definition at line 628 of file audio_kernels.c.
References CK_AUDIO_WHISPER_HOP_LENGTH, CK_AUDIO_WHISPER_N_FFT, CK_AUDIO_WHISPER_POWER_BINS, and reflect_index().
Referenced by audio_stft_power_fft400_f32(), and audio_whisper_log_mel_window_wav_pcm16_f32().
| int audio_stft_power_precomputed_f32 | ( | const float * | samples, |
| int | n_samples, | ||
| const float * | window, | ||
| const float * | cos_table, | ||
| const float * | sin_table, | ||
| int | n_fft, | ||
| int | hop_length, | ||
| float * | power, | ||
| int | n_frames | ||
| ) |
Definition at line 454 of file audio_kernels.c.
References reflect_index().
| int audio_stft_precompute_tables_f32 | ( | int | n_fft, |
| float * | window, | ||
| float * | cos_table, | ||
| float * | sin_table | ||
| ) |
Definition at line 370 of file audio_kernels.c.
References CK_AUDIO_PI_F.
| int audio_transpose_channel_to_token_f32 | ( | const float * | input, |
| float * | output, | ||
| int | channels, | ||
| int | frames | ||
| ) |
Definition at line 1207 of file audio_kernels.c.
| int audio_wav_decode_memory_pcm16_mono_f32 | ( | const uint8_t * | bytes, |
| size_t | byte_count, | ||
| float * | mono, | ||
| int | mono_capacity, | ||
| CKAudioWavInfo * | info | ||
| ) |
Definition at line 133 of file audio_kernels.c.
References audio_wav_decode_memory_pcm16_mono_window_f32().
| int audio_wav_decode_memory_pcm16_mono_window_f32 | ( | const uint8_t * | bytes, |
| size_t | byte_count, | ||
| int | start_frame, | ||
| float * | mono, | ||
| int | mono_capacity, | ||
| CKAudioWavInfo * | info | ||
| ) |
Definition at line 144 of file audio_kernels.c.
References audio_wav_parse_memory(), CKAudioWavInfo::channels, CKAudioWavInfo::data_offset, CKAudioWavInfo::frames, and read_u16_le().
Referenced by audio_wav_decode_memory_pcm16_mono_f32().
| int audio_wav_decode_pcm16_mono_f32 | ( | const uint8_t * | bytes, |
| size_t | byte_count, | ||
| const CKAudioWavInfo * | info, | ||
| float * | mono, | ||
| int | mono_capacity | ||
| ) |
Definition at line 105 of file audio_kernels.c.
References CKAudioWavInfo::bits_per_sample, CKAudioWavInfo::channels, CKAudioWavInfo::data_bytes, CKAudioWavInfo::data_offset, CKAudioWavInfo::format_tag, CKAudioWavInfo::frames, and read_u16_le().
Referenced by audio_whisper_log_mel_window_wav_pcm16_f32().
| int audio_wav_parse_memory | ( | const uint8_t * | bytes, |
| size_t | byte_count, | ||
| CKAudioWavInfo * | info | ||
| ) |
Definition at line 44 of file audio_kernels.c.
References CKAudioWavInfo::bits_per_sample, CKAudioWavInfo::channels, CKAudioWavInfo::data_bytes, CKAudioWavInfo::data_offset, CKAudioWavInfo::format_tag, CKAudioWavInfo::frames, read_u16_le(), read_u32_le(), and CKAudioWavInfo::sample_rate.
Referenced by audio_wav_decode_memory_pcm16_mono_window_f32(), and audio_whisper_log_mel_window_wav_pcm16_f32().
| int audio_whisper_log_mel_from_power_reference_f32 | ( | const float * | power, |
| const float * | mel_filters, | ||
| int | n_mels, | ||
| int | n_frames, | ||
| float * | log_mel | ||
| ) |
Definition at line 1269 of file audio_kernels.c.
References CK_AUDIO_WHISPER_POWER_BINS.
Referenced by audio_whisper_log_mel_reference_f32().
| int audio_whisper_log_mel_reference_f32 | ( | const float * | samples, |
| int | n_samples, | ||
| const float * | mel_filters, | ||
| int | n_mels, | ||
| float * | power_scratch, | ||
| float * | log_mel, | ||
| int | n_frames | ||
| ) |
Definition at line 1309 of file audio_kernels.c.
References audio_whisper_log_mel_from_power_reference_f32(), and audio_whisper_stft_power_reference_f32().
| int audio_whisper_log_mel_window_wav_pcm16_f32 | ( | const uint8_t * | bytes, |
| size_t | byte_count, | ||
| int | start_frame, | ||
| int | target_sample_rate, | ||
| const float * | window, | ||
| const float * | cos_table, | ||
| const float * | sin_table, | ||
| const float * | mel_filters, | ||
| int | n_mels, | ||
| int | output_frames, | ||
| float * | log_mel | ||
| ) |
Definition at line 681 of file audio_kernels.c.
References audio_stft_power_fft400_frame_f32(), audio_wav_decode_pcm16_mono_f32(), audio_wav_parse_memory(), CK_AUDIO_WHISPER_HOP_LENGTH, CK_AUDIO_WHISPER_N_FFT, CK_AUDIO_WHISPER_POWER_BINS, CK_AUDIO_WHISPER_SAMPLE_RATE, CKAudioWavInfo::frames, and CKAudioWavInfo::sample_rate.
| int audio_whisper_mel_filters_slaney_f32 | ( | int | sample_rate, |
| int | n_fft, | ||
| int | n_mels, | ||
| float * | mel_filters | ||
| ) |
Definition at line 415 of file audio_kernels.c.
References audio_hz_to_mel_slaney(), audio_mel_to_hz_slaney(), left, and right.
| int audio_whisper_stft_power_reference_f32 | ( | const float * | samples, |
| int | n_samples, | ||
| float * | power, | ||
| int | n_frames | ||
| ) |
Definition at line 1228 of file audio_kernels.c.
References CK_AUDIO_PI_F, CK_AUDIO_WHISPER_HOP_LENGTH, CK_AUDIO_WHISPER_N_FFT, CK_AUDIO_WHISPER_POWER_BINS, and reflect_index().
Referenced by audio_whisper_log_mel_reference_f32().
|
static |
Definition at line 800 of file audio_kernels.c.
Referenced by audio_conv1d_channel_major_f32().
|
static |
Definition at line 976 of file audio_kernels.c.
References end.
Referenced by audio_conv2d_whc_grouped_f32().
|
static |
Definition at line 1104 of file audio_kernels.c.
References end.
Referenced by audio_glu_split_channel_major_f32().
|
static |
Definition at line 1155 of file audio_kernels.c.
References end.
Referenced by audio_relative_shift_f32().
|
static |
Definition at line 33 of file audio_kernels.c.
Referenced by audio_wav_decode_memory_pcm16_mono_window_f32(), audio_wav_decode_pcm16_mono_f32(), and audio_wav_parse_memory().
|
static |
Definition at line 38 of file audio_kernels.c.
Referenced by audio_wav_parse_memory().
|
static |
Definition at line 21 of file audio_kernels.c.
Referenced by audio_stft_power_centered_window_f32(), audio_stft_power_fft400_frame_f32(), audio_stft_power_precomputed_f32(), and audio_whisper_stft_power_reference_f32().