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.BlockRandom interleaver permuting a sequence of input symbols.
- Parameters:
seed (int | None) – Integer defining the random seed used if
keep_stateis 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
seedattribute).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,
precisionis used.device (str | None) – Device for computation (e.g., ‘cpu’, ‘cuda:0’). If None,
deviceis used.
- Inputs:
x – torch.Tensor. Tensor of arbitrary shape and dtype.
seed – int. 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
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_stopis an additional stopping condition, i.e., stop if current \(S\) is already smaller thans_min_stop.