ViterbiDecoder#
- class sionna.phy.fec.conv.ViterbiDecoder(*, encoder: ConvEncoder | None = None, gen_poly: Tuple[str, ...] | None = None, rate: float = 0.5, constraint_length: int = 3, rsc: bool = False, terminate: bool = False, method: str = 'soft_llr', return_info_bits: bool = True, precision: str | None = None, device: str | None = None, **kwargs)[source]#
Bases:
sionna.phy.block.BlockApplies Viterbi decoding to a sequence of noisy codeword bits.
Implements the Viterbi decoding algorithm [Viterbi] that returns an estimate of the information bits for a noisy convolutional codeword. Takes as input either LLR values (
method='soft_llr') or hard bit values (method='hard') and returns a hard decided estimation of the information bits.- Parameters:
encoder (ConvEncoder | None) – If
encoderis provided as input, the following input parameters are not required and will be ignored:gen_poly,rate,constraint_length,rsc,terminate. They will be inferred from theencoderobject itself. If None, the above parameters must be provided explicitly.gen_poly (Tuple[str, ...] | None) – Tuple of strings with each string being a 0,1 sequence. If None,
rateandconstraint_lengthmust be provided.rate (float) – Valid values are 1/3 and 0.5. Only required if
gen_polyis None.constraint_length (int) – Valid values are between 3 and 8 inclusive. Only required if
gen_polyis None.rsc (bool) – Boolean flag indicating whether the encoder is recursive-systematic for given generator polynomials. True indicates encoder is recursive-systematic. False indicates encoder is feed-forward non-systematic. Defaults to False.
terminate (bool) – Boolean flag indicating whether the codeword is terminated. True indicates codeword is terminated to all-zero state. False indicates codeword is not terminated. Defaults to False.
method (str) – Valid values are
'soft_llr'or'hard'. In computing path metrics,'soft_llr'expects channel LLRs as input.'hard'assumes a binary symmetric channel (BSC) with 0/1 values as inputs. In case of'hard', inputs will be quantized to 0/1 values.return_info_bits (bool) – Boolean flag indicating whether only the information bits or all codeword bits are returned. Defaults to True.
precision (str | None) – Precision used for internal calculations and outputs. If None,
precisionis used.device (str | None) – Device for computation (e.g., ‘cpu’, ‘cuda:0’). If None,
deviceis used.
- Inputs:
inputs – […, n], torch.float. Tensor containing the (noisy) channel output symbols where
ndenotes the codeword length.- Outputs:
output – […, rate * n], torch.float. Binary tensor containing the estimates of the information bit tensor.
Notes
A full implementation of the decoder rather than a windowed approach is used. For a given codeword of duration
T, the path metric is computed from time0toTand the path with optimal metric at timeTis selected. The optimal path is then traced back fromTto0to output the estimate of the information bit vector used to encode. For larger codewords, note that the current method is sub-optimal in terms of memory utilization and latency. This method is also excluded fromtorch.compileusing@torch.compiler.disablebecause the Viterbi algorithm’s inherently sequential structure (forward pass, traceback, output extraction) causes extremely long compilation times due to loop unrolling.Examples
from sionna.phy.fec.conv import ViterbiDecoder decoder = ViterbiDecoder(rate=0.5, constraint_length=5) llr = torch.randn(10, 200) # Received LLRs u_hat = decoder(llr) print(u_hat.shape) # torch.Size([10, 100])
Attributes
- property trellis: sionna.phy.fec.conv.utils.Trellis#
Trellis object used during encoding.
Methods
- build(input_shape: torch.Size)[source]#
Build block and check dimensions.
- Parameters:
input_shape (torch.Size)