ConvEncoder#
- class sionna.phy.fec.conv.ConvEncoder(gen_poly: Tuple[str, ...] | None = None, rate: float = 0.5, constraint_length: int = 3, rsc: bool = False, terminate: bool = False, precision: str | None = None, device: str | None = None, **kwargs)[source]#
Bases:
sionna.phy.block.BlockEncodes an information binary tensor to a convolutional codeword.
Currently, only generator polynomials for codes of rate=1/n for n=2,3,4,… are allowed.
- Parameters:
gen_poly (Tuple[str, ...] | None) – Sequence 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 Trellis generated is recursive systematic or not. If True, the encoder is recursive-systematic. In this case first polynomial in
gen_polyis used as the feedback polynomial. Defaults to False.terminate (bool) – Encoder is terminated to all zero state if True. If terminated, the true rate of the code is slightly lower than
rate.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 where
kis the information length.- Outputs:
cw – […, k/rate], torch.float. Binary tensor containing the encoded codeword for the given input information tensor where
rateis \(\frac{1}{\textrm{len}\left(\textrm{gen\_poly}\right)}\) (ifgen_polyis provided).
Notes
The generator polynomials from [Moon] are available for various rate and constraint lengths. To select them, use the
rateandconstraint_lengtharguments.In addition, polynomials for any non-recursive convolutional encoder can be given as input via
gen_polyargument. Currently, only polynomials with rate=1/n are supported. When thegen_polyargument is given, therateandconstraint_lengtharguments are ignored.Various notations are used in the literature to represent the generator polynomials for convolutional codes. In [Moon], the octal digits format is primarily used. In the octal format, the generator polynomial 10011 corresponds to 46. Another widely used format is decimal notation with MSB. In this notation, polynomial 10011 corresponds to 19. For simplicity, the
ConvEncoderonly accepts the bit format i.e. 10011 asgen_polyargument.Also note that
constraint_lengthandmemoryare two different terms often used to denote the strength of a convolutional code. In this sub-package, we useconstraint_length. For example, the polynomial 10011 has aconstraint_lengthof 5, however itsmemoryis only 4.When
terminateis True, the true rate of the convolutional code is slightly lower thanrate. It equals \(\frac{r*k}{k+\mu}\) where r denotesrateand \(\mu\) isconstraint_length- 1. For example whenterminateis True,k=100, \(\mu=4\) andrate=0.5, true rate equals \(\frac{0.5*100}{104}=0.481\).Examples
from sionna.phy.fec.conv import ConvEncoder encoder = ConvEncoder(rate=0.5, constraint_length=5) u = torch.randint(0, 2, (10, 100), dtype=torch.float32) c = encoder(u) print(c.shape) # torch.Size([10, 200])
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) – Shape of input tensor (…, k)