Expand description
Mel-filterbank apply as a certified forge kernel.
Projects a row-major power spectrum (n_frames × n_bins) onto a triangular mel
filterbank (n_mel × n_bins), producing mel energies (n_frames × n_mel). The
operation is the matrix contraction
mel_out[f, m] = Σ_b spectrum[f, b] · mel_fb[m, b].
Embeds shaders/audio_mel.wgsl via include_str!
(single source of truth), grades it against the exact CPU oracle mel_apply_cpu,
and runs it on the auxiliary GPU circuit via mel_apply_forge. The public entry
point mel_apply prefers the GPU when one is present and otherwise uses the CPU
floor, so the call is never broken.
Circuit placement: the forge kernel runs on the auxiliary circuit (the iGPU when
present) so the primary/discrete GPU stays free for the LLM. Device selection goes
through crate::gpu_context::device_registry::try_auxiliary_gpu, which falls back
auxiliary → primary → None; on None the forge path returns
ForgeError::GpuUnavailable and mel_apply drops to the CPU floor — i.e. the
effective placement chain is auxiliary → primary → CPU.
Constants§
- MEL_
APPLY_ ENTRY - Entry-point name of
MEL_APPLY_WGSL. - MEL_
APPLY_ WGSL - The mel-apply kernel source (embedded from the canonical
.wgsl).
Functions§
- mel_
apply - Public entry point: run the mel-filterbank apply on the best path available on this
machine. If a wgpu adapter is present (
caps().wgpu), trymel_apply_forgeand return its result on success; otherwise (no adapter, or a runtime GPU failure) fall back to the exact CPU oraclemel_apply_cpu, so the call is never broken. - mel_
apply_ cpu - Exact CPU oracle for the mel-filterbank apply. Mirrors the WGSL scalar-for-scalar:
for each output element
(frame, m), accumulatesspectrum[frame, b] · mel_fb[m, b]overbin increasing order.spectrumis row-majorn_frames × n_bins,mel_fbis row-majorn_mel × n_bins; the result is row-majorn_frames × n_mel. - mel_
apply_ forge - Run the mel-filterbank apply on the GPU and read back the result. Runs on the
auxiliary GPU circuit (the iGPU when present) to keep the primary/discrete GPU
free for the LLM: the device is taken from
crate::gpu_context::device_registry::try_auxiliary_gpu(falls back auxiliary → primary →None) and the compute context is built with [WgpuComputeContext::from_device] on that shared device, rather than requesting its own HighPerformance adapter.