CRCEncoder#
- class sionna.phy.fec.crc.CRCEncoder(crc_degree: str, *, k: int | None = None, precision: str | None = None, device: str | None = None, **kwargs)[source]#
Bases:
sionna.phy.block.BlockAdds a Cyclic Redundancy Check (CRC) to the input sequence.
The CRC polynomials from Sec. 5.1 in [3GPPTS38212] are available: {CRC24A, CRC24B, CRC24C, CRC16, CRC11, CRC6}.
- Parameters:
crc_degree (str) – Defines the CRC polynomial to be used. Can be any value from {CRC24A, CRC24B, CRC24C, CRC16, CRC11, CRC6}.
k (int | None) – Optional number of input bits. If specified, the generator matrix is pre-built during initialization, which is required for
torch.compilecompatibility. If not specified, the matrix is built lazily on first call.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 of arbitrary shape where the last dimension is […, k].
- Outputs:
x_crc – […, k + crc_length], torch.float. Binary tensor containing CRC-encoded bits of the same shape as
bitsexcept the last dimension changes to […, k + crc_length].
Notes
For performance enhancements, a generator-matrix-based implementation is used for fixed k instead of the more common shift register-based operations. Thus, the encoder must trigger an (internal) rebuild if k changes.
Examples
import torch from sionna.phy.fec.crc import CRCEncoder encoder = CRCEncoder("CRC24A") bits = torch.randint(0, 2, (10, 100), dtype=torch.float32) encoded = encoder(bits) print(encoded.shape) # torch.Size([10, 124])
Attributes
- property crc_pol: numpy.ndarray#
CRC polynomial in binary representation.
Methods