Operations
One at a time
Section titled “One at a time”Each call uploads its input, runs, and returns NumPy.
import dspk
y = dspk.ops.filter.iir(x, 30_000.0, "bandpass", (300.0, 6000.0))y = dspk.ops.spatial.cmr(y)As a chain
Section titled “As a chain”Two separate calls move the data to the device and back twice. A
Pipeline does one upload, every stage, one download.
from dspk.ops import Pipeline, stage
chain = Pipeline([stage.iir("bandpass", (300.0, 6000.0)), stage.cmr()], 30_000.0)y = chain.process(x)Chunks of a long signal
Section titled “Chunks of a long signal”stream=True treats chunks as consecutive pieces of one signal. Filter state carries over, so the
output equals processing the whole signal at once. It needs causal filters:
chain = Pipeline([stage.iir("highpass", 300.0, mode="forward"), stage.cmr()], 30_000.0, stream=True)for chunk in chunks: y = chain.process(chunk)Without stream, each chunk stands alone, and
settling says how much context it needs to match the
whole signal.
Picking a runtime
Section titled “Picking a runtime”Every call takes runtime="cuda" and so on, or set one for everything with dspk.runtime.set.
See Operations for what’s available.