LDPC5GEncoder#
- class sionna.phy.fec.ldpc.LDPC5GEncoder(k: int, n: int, num_bits_per_symbol: int | None = None, bg: str | None = None, precision: str | None = None, device: str | None = None, **kwargs)[source]#
Bases:
sionna.phy.block.Block5G NR LDPC Encoder following the 3GPP 38.212 including rate-matching.
The implementation follows the 3GPP NR Initiative [3GPPTS38212].
- Parameters:
k (int) – Number of information bits per codeword.
n (int) – Desired codeword length.
num_bits_per_symbol (int | None) – Number of bits per QAM symbol. If provided, the codeword will be interleaved after rate-matching as specified in Sec. 5.4.2.2 in [3GPPTS38212].
bg (str | None) – Basegraph to be used for the code construction. If None, the encoder will automatically select the basegraph according to [3GPPTS38212].
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:
bits – […, k], torch.float. Binary tensor containing the information bits to be encoded.
- Outputs:
cw – […, n], torch.float. Binary tensor of same shape as inputs besides last dimension has changed to n containing the encoded codeword bits.
Notes
As specified in [3GPPTS38212], the encoder also performs rate-matching (puncturing and shortening). Thus, the corresponding decoder needs to invert these operations, i.e., must be compatible with the 5G encoding scheme.
Examples
import torch from sionna.phy.fec.ldpc import LDPC5GEncoder # Create encoder for k=100 information bits and n=200 codeword bits encoder = LDPC5GEncoder(k=100, n=200) # Generate random information bits u = torch.randint(0, 2, (10, 100), dtype=torch.float32) c = encoder(u) print(c.shape) # torch.Size([10, 200])
Attributes
- property pcm: scipy.sparse._csr.csr_matrix#
Parity-check matrix for given code parameters.
- property num_bits_per_symbol: int | None#
Modulation order used for the rate-matching output interleaver.
- property out_int: torch.Tensor#
Output interleaver sequence as defined in 5.4.2.2.
- property out_int_inv: torch.Tensor#
Inverse output interleaver sequence as defined in 5.4.2.2.
Methods
- generate_out_int(n: int, num_bits_per_symbol: int) Tuple[numpy.ndarray, numpy.ndarray][source]#
Generates LDPC output interleaver sequence as defined in Sec 5.4.2.2 in [3GPPTS38212].
- Parameters:
Notes
The interleaver pattern depends on the modulation order and helps to reduce dependencies in bit-interleaved coded modulation (BICM) schemes combined with higher order modulation.