API Reference
torchstreamer
Streamers for core PyTorch modules
BaseStream
Base class for all streamers
forward(x, final=False)
abstractmethod
Processes an input tensor through the stream
| Parameters: |
|
|---|
| Returns: |
|
|---|
Sequential1dStream
Streamer for torch.nn.Sequential networks over 1D [B, C, T] tensors
| Parameters: |
|
|---|
Example
net = nn.Sequential(
nn.Conv1d(1, 128, 1),
nn.Conv1d(128, 1, 1),
)
stream = pts.Sequential1dStream(net)
Residual1dStream
Streamer for ResNets
This streamer streams over the inner layers of a residual network (the part without the residual connection). It buffers the inputs so that they can be added (without padding) to the outputs after processing through the network's receptive field.
| Parameters: |
|
|---|
Example
net = pts.Residual1d(
nn.Conv1d(1, 128, 1),
nn.Conv1d(128, 1, 1),
)
stream = pts.Residual1dStream(net)
Residual1d
PyTorch module for wrapping a network with a residual connection
Note this is not a streamer, just a utility module to make it easier to build streamable residual networks.
| Parameters: |
|
|---|
| Raises: |
|
|---|
Example
net = nn.Sequential(
nn.Conv1d(1, 128, 1),
pts.Residual1d(
nn.GELU(),
nn.Conv1d(128, 256, 1),
nn.GELU(),
nn.Conv1d(256, 128, 1),
),
nn.Conv1d(128, 1, 1),
)
Conv1dStream
Streamer for Conv1d modules
Note that the stream ignores any padding configuration for the convolution, performing an exact (valid) convolution instead.
| Parameters: |
|
|---|
ConvTranspose1dStream
Streamer for ConvTranspose1d modules
Note that the stream ignores any padding configuration for the convolution, performing an exact (valid) transposed convolution instead.
| Parameters: |
|
|---|
Pool1dStream
Streamer for PyTorch pooling modules (AvgPool1d/MaxPool1d)
| Parameters: |
|
|---|
| Raises: |
|
|---|
Elementwise1dStream
Streamer for simple pointwise/elementwise PyTorch modules
Elementwise modules are modules that do not have a spatial receptive field, so operations do not span or stride the final dimension.
| Parameters: |
|
|---|
register_streamer(module, streamer)
Registers a new stream for a PyTorch module type
Note that custom streamers are not needed for simple elementwise modules, these are wrapped automatically with Elementwise1dStream instances. Custom streamers are only needed for custom modules that process more than one spatial element at a time.
| Parameters: |
|
|---|
Example
class MyModule(nn.Module):
...
class MyModuleStream(pts.BaseStream):
def __init__(self, net: MyModule):
...
register_streamer(MyModule, lambda net: MyModuleStream(net))
create_stream(net)
Finds and creates a stream handler for a registered or built-in module
| Parameters: |
|
|---|
| Returns: |
|
|---|
Example
stream = create_stream(nn.Conv1d(1, 128, 1))
torchstreamer.audio
Streamers for audio signals and TorchAudio modules
ResampleStream
Audio sample rate conversion streamer
This streamer performs the same operation as torchaudio.functional.resample
in a streaming fashion, buffering inputs as needed to match the
non-streamed outputs exactly. Inputs can be shaped [T] or [C, T],
and the tensor rank will be preserved in the outputs.
| Parameters: |
|
|---|