TBDecoder#

class sionna.phy.nr.TBDecoder(encoder: sionna.phy.nr.tb_encoder.TBEncoder, num_bp_iter: int = 20, cn_update: str | callable = 'boxplus-phi', vn_update: str | callable = 'sum', precision: str | None = None, device: str | None = None, **kwargs)[source]#

Bases: sionna.phy.block.Block

5G NR transport block (TB) decoder as defined in TS 38.214 [3GPPTS38214].

The transport block decoder takes as input a sequence of noisy channel observations and reconstructs the corresponding transport block of information bits. The detailed procedure is described in TS 38.214 [3GPPTS38214] and TS 38.211 [3GPPTS38211].

Parameters:
  • encoder (sionna.phy.nr.tb_encoder.TBEncoder) – Associated transport block encoder used for encoding of the signal.

  • num_bp_iter (int) – Number of BP decoder iterations. Defaults to 20.

  • cn_update (str | callable) – Check node update rule for BP decoding. One of “boxplus-phi”, “boxplus”, “minsum”, “offset-minsum”, “identity”, or a callable. If a callable is provided, it will be used instead as CN update. Defaults to “boxplus-phi”.

  • vn_update (str | callable) – Variable node update rule for BP decoding. One of “sum”, “identity”, or a callable. If a callable is provided, it will be used instead as VN update. Defaults to “sum”.

  • precision (str | None) – Precision used for internal calculations and outputs. If set to None, precision is used.

  • device (str | None) – Device for computation.

Inputs:

inputs – […, num_coded_bits], torch.float. 2+D tensor containing channel logits/LLR values of the (noisy) channel observations.

Outputs:
  • b_hat – […, target_tb_size], torch.float. 2+D tensor containing hard decided bit estimates of all information bits of the transport block.

  • tb_crc_status – […], torch.bool. Transport block CRC status indicating if a transport block was (most likely) correctly recovered. Note that false positives are possible.

Examples

import torch
from sionna.phy.nr import TBEncoder, TBDecoder

# Create encoder and decoder
encoder = TBEncoder(
    target_tb_size=1000,
    num_coded_bits=2000,
    target_coderate=0.5,
    num_bits_per_symbol=4,
    n_rnti=1,
    n_id=1
)
decoder = TBDecoder(encoder, num_bp_iter=20)

# Encode and decode
bits = torch.randint(0, 2, (10, 1000), dtype=torch.float32)
coded = encoder(bits)
llr = 10.0 * (2.0 * coded - 1.0)  # High SNR LLRs
bits_hat, crc_ok = decoder(llr)
print(bits_hat.shape, crc_ok.shape)
# torch.Size([10, 1000]) torch.Size([10])

Attributes

property tb_size: int#

Number of information bits per TB.

property k: int#

Number of input information bits. Equals TB size.

property n: int#

Total number of output codeword bits.

Methods

build(input_shape: tuple) None[source]#

Test input shapes for consistency.

Parameters:

input_shape (tuple)