convolve#
- sionna.phy.signal.convolve(inp: torch.Tensor, ker: torch.Tensor, padding: Literal['full', 'same', 'valid'] = 'full', axis: int = -1, precision: Literal['single', 'double'] | None = None) torch.Tensor[source]#
Filters an input
inpof length N by convolving it with a kernelkerof length K.The length of the kernel
kermust not be greater than the one of the input sequenceinp.The dtype of the output is torch.float only if both
inpandkerare torch.float. It is torch.complex otherwise.inpandkermust have the same precision.Three padding modes are available:
“full” (default): Returns the convolution at each point of overlap between
kerandinp. The length of the output is N + K - 1. Zero-padding of the inputinpis performed to compute the convolution at the border points.“same”: Returns an output of the same length as the input
inp. The convolution is computed such that the coefficients of the inputinpare centered on the coefficient of the kernelkerwith index(K-1)/2for kernels of odd length, andK/2 - 1for kernels of even length. Zero-padding of the input signal is performed to compute the convolution at the border points.“valid”: Returns the convolution only at points where
inpandkercompletely overlap. The length of the output is N - K + 1.
- Parameters:
inp (torch.Tensor) – Input to filter with shape […, N] (torch.complex or torch.float)
ker (torch.Tensor) – Kernel of the convolution with shape [K] (torch.complex or torch.float)
padding (Literal['full', 'same', 'valid']) – Padding mode. One of “full” (default), “valid”, or “same”.
axis (int) – Axis along which to perform the convolution
precision (Literal['single', 'double'] | None) – Precision used for internal calculations and outputs. If set to None,
precisionis used.
- Outputs:
out – […, M], torch.complex or torch.float. Convolution output. The length M of the output depends on the
padding.
Examples
import torch from sionna.phy.signal import convolve inp = torch.randn(64, 100) ker = torch.randn(10) out = convolve(inp, ker, padding="same") print(out.shape) # torch.Size([64, 100])