CUDA kernel¶
gammatone_kernel
¶
Custom CUDA kernel for batched IIR (SOS) filtering.
Applies a different SOS filter to the same input signal on every channel in a single kernel launch, replacing a Python-level loop of N independent cupyx.scipy.signal.sosfilt calls.
Falls back gracefully: is_available() returns False whenever CuPy or
nvrtc cannot be used, and callers should keep the original loop as a
fallback path.
is_available
¶
Return True iff CuPy + nvrtc can compile this kernel on this machine.
Triggers a one-time JIT compile of a tiny stub kernel; subsequent calls hit the kernel cache and are essentially free.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the kernel can be used. False on CPU-only systems or when nvrtc is missing. |
batched_sosfilt
¶
batched_sosfilt(sos: 'cp.ndarray', x: 'cp.ndarray', gain: float = 1.0, out: Optional['cp.ndarray'] = None, precision: str = 'float64') -> 'cp.ndarray'
Apply a per-channel SOS cascade to the same input in one kernel launch.
Equivalent to a loop of cupyx.scipy.signal.sosfilt calls, each
with its own SOS coefficients but a shared input signal, fused into
a single CUDA kernel.
| PARAMETER | DESCRIPTION |
|---|---|
sos
|
SOS coefficients of shape
TYPE:
|
x
|
Shared 1D input signal of shape
TYPE:
|
gain
|
Per-channel scalar applied to the output before write-back.
TYPE:
|
out
|
Pre-allocated output buffer of shape
TYPE:
|
precision
|
Internal compute precision.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ndarray
|
Filtered output of shape |
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If CuPy is not installed. |
ValueError
|
If |
TypeError
|
If |