SymbolDemapper#

class sionna.phy.mapping.SymbolDemapper(constellation_type: str | None = None, num_bits_per_symbol: int | None = None, constellation: sionna.phy.mapping.Constellation | None = None, hard_out: bool = False, precision: Literal['single', 'double'] | None = None, device: str | None = None, **kwargs: Any)[source]#

Bases: sionna.phy.block.Block

Computes normalized log-probabilities (logits) or hard-decisions on symbols for a tensor of received symbols.

Prior knowledge on the transmitted constellation points can be optionally provided. The demapping function is fully differentiable when soft-values are computed.

Parameters:
  • constellation_type (str | None) – Type of constellation. One of “qam”, “pam”, or “custom”. For “custom”, an instance of Constellation must be provided.

  • num_bits_per_symbol (int | None) – Number of bits per constellation symbol, e.g., 4 for QAM16. Only required for constellation_type in [“qam”, “pam”].

  • constellation (sionna.phy.mapping.Constellation | None) – If no constellation is provided, constellation_type and num_bits_per_symbol must be provided. Defaults to None.

  • hard_out (bool) – If True, the demapper provides hard-decided symbols instead of soft-values. Defaults to False.

  • precision (Literal['single', 'double'] | None) – Precision used for internal calculations and outputs. If set to None, precision is used.

  • device (str | None) – Device for tensor operations. If None, device is used.

  • kwargs (Any)

Inputs:
  • y – […, n], torch.complex. Received symbols.

  • no – Scalar or […, n], torch.float. Noise variance estimate. It can be provided either as scalar for the entire input batch or as a tensor that is “broadcastable” to y.

  • priorNone (default) | [num_points] or […, num_points], torch.float. Prior for every symbol as log-probabilities (logits). It can be provided either as a tensor of shape [num_points] for the entire input batch, or as a tensor that is “broadcastable” to […, n, num_points].

Outputs:

logits – […, n, num_points] or […, n], torch.float or torch.int32. A tensor of shape […, n, num_points] of logits for every constellation point if hard_out is set to False. Otherwise, a tensor of shape […, n] of hard-decisions on the symbols.

Notes

The normalized log-probability for the constellation point \(c\) is computed according to

\[\ln\left(\Pr\left(c \lvert y,\mathbf{p}\right)\right) = \ln\left( \frac{\exp\left(-\frac{|y-c|^2}{N_0} + p_c \right)}{\sum_{c'\in\mathcal{C}} \exp\left(-\frac{|y-c'|^2}{N_0} + p_{c'} \right)} \right)\]

where \(\mathcal{C}\) is the set of constellation points used for modulation, and \(\mathbf{p} = \left\{p_c \lvert c \in \mathcal{C}\right\}\) the prior information on constellation points given as log-probabilities and which is set to \(\mathbf{0}\) if no prior information on the constellation points is assumed to be available.

Examples

import torch
from sionna.phy.mapping import Mapper, SymbolDemapper

mapper = Mapper("qam", 4)
demapper = SymbolDemapper("qam", 4)

bits = torch.randint(0, 2, (10, 100), dtype=torch.float32)
symbols = mapper(bits)

# Add noise
noise = 0.1 * torch.randn_like(symbols)
y = symbols + noise

# Compute symbol logits
logits = demapper(y, no=0.01)
print(logits.shape)
# torch.Size([10, 25, 16])