PolarEncoder#
- class sionna.phy.fec.polar.PolarEncoder(frozen_pos: numpy.ndarray, n: int, *, precision: str | None = None, device: str | None = None, **kwargs)[source]#
Bases:
sionna.phy.block.BlockPolar encoder for given code parameters.
This block performs polar encoding for the given
kinformation bits and the frozen set (i.e., indices of frozen positions) specified byfrozen_pos.- Parameters:
frozen_pos (numpy.ndarray) – Array of int defining the n-k frozen indices, i.e., information bits are mapped onto the k complementary positions.
n (int) – Defining the codeword length.
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 containing the codeword bits.
Notes
As commonly done, we assume frozen bits are set to 0. Please note that - although its practical relevance is only little - setting frozen bits to 1 may result in affine codes instead of linear code as the all-zero codeword is not necessarily part of the code any more.
Examples
import torch from sionna.phy.fec.polar import PolarEncoder from sionna.phy.fec.polar.utils import generate_5g_ranking k, n = 100, 256 frozen_pos, _ = generate_5g_ranking(k, n) encoder = PolarEncoder(frozen_pos, n) bits = torch.randint(0, 2, (10, k), dtype=torch.float32) codewords = encoder(bits) print(codewords.shape) # torch.Size([10, 256])
Attributes
- property frozen_pos: numpy.ndarray#
Frozen positions for Polar decoding.
- property info_pos: numpy.ndarray#
Information bit positions for Polar encoding.
Methods