RandomInterleaver#

class sionna.phy.fec.interleaving.RandomInterleaver(seed: int | None = None, keep_batch_constant: bool = True, inverse: bool = False, keep_state: bool = True, axis: int = -1, precision: str | None = None, device: str | None = None, **kwargs)[source]#

Bases: sionna.phy.block.Block

Random interleaver permuting a sequence of input symbols.

Parameters:
  • seed (int | None) – Integer defining the random seed used if keep_state is True.

  • keep_batch_constant (bool) – If True, each sample in the batch uses the same permutation. Otherwise, unique permutations per batch sample are generated (slower).

  • inverse (bool) – If True, the inverse permutation is performed.

  • keep_state (bool) – If True, the permutation is fixed for multiple calls (defined by seed attribute).

  • axis (int) – The dimension that should be interleaved. First dimension (axis=0) is not allowed.

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

  • device (str | None) – Device for computation (e.g., ‘cpu’, ‘cuda:0’). If None, device is used.

Inputs:
  • x – torch.Tensor. Tensor of arbitrary shape and dtype.

  • seedint. An integer defining the state of the random number generator. If explicitly given, the global internal seed is replaced by this seed. Can be used to realize random interleaver/deinterleaver pairs (call with same random seed).

Outputs:

x_int – torch.Tensor. Tensor of same shape and dtype as the input x.

Notes

The interleaver block is stateless, i.e., the seed is either random during each call or must be explicitly provided during init/call.

This is NOT the 5G interleaver sequence.

Examples

import torch
from sionna.phy.fec.interleaving import RandomInterleaver

interleaver = RandomInterleaver(seed=42, keep_state=True)
x = torch.arange(10).reshape(1, 10).float()
y = interleaver(x)
print(y)

Attributes

property seed: int#

Seed to generate random sequence.

property axis: int#

Axis to be permuted.

property keep_state: bool#

Generate new random seed per call.

Methods

find_s_min(seed: int, seq_length: int, s_min_stop: int = 0) int[source]#

Find \(S\) parameter such that \(\pi(i)-\pi(j)>S\) for all \(i-j<S\). This can be used to find optimized interleaver patterns.

s_min_stop is an additional stopping condition, i.e., stop if current \(S\) is already smaller than s_min_stop.

Parameters:
  • seed (int) – Seed to draw random permutation that shall be analyzed.

  • seq_length (int) – Length of permutation sequence to be analyzed.

  • s_min_stop (int) – Enables early stop if already current s_min < s_min_stop.

Outputs:

s_min – The S-parameter for the given seed.

build(input_shape: tuple, **kwargs) None[source]#

Build block and check consistency of dimensions.

Parameters:

input_shape (tuple) – Shape of input tensor.