forked from NVlabs/sionna
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement transform precoding (preliminary draft)
- Loading branch information
1 parent
8ad32bc
commit e2e2d57
Showing
9 changed files
with
412 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import tensorflow as tf | ||
|
||
import sionna | ||
from sionna.utils import split_dim | ||
from .pusch_transform_precoder import PUSCHTransformDeprecoder | ||
|
||
|
||
class LinearTransformPrecodingMimoDetector(sionna.mimo.detection.LinearDetector): | ||
def __init__(self, | ||
equalizer, | ||
output, | ||
demapping_method, | ||
num_subcarriers, | ||
constellation_type=None, | ||
num_bits_per_symbol=None, | ||
constellation=None, | ||
hard_out=False, | ||
dtype=tf.complex64, | ||
**kwargs): | ||
super().__init__(equalizer, output, demapping_method, constellation_type, num_bits_per_symbol, constellation, | ||
hard_out, dtype, **kwargs) | ||
self._transform_deprecoder = PUSCHTransformDeprecoder(num_subcarriers, dtype) | ||
|
||
def call(self, inputs): | ||
x_hat, no_eff = self._equalizer(*inputs) | ||
x_transform_deprecoded = self._transform_deprecoder(x_hat) | ||
z = self._demapper([x_transform_deprecoded, no_eff]) | ||
|
||
# Reshape to the expected output shape | ||
num_streams = tf.shape(inputs[1])[-1] | ||
if self._output == 'bit': | ||
num_bits_per_symbol = self._constellation.num_bits_per_symbol | ||
z = split_dim(z, [num_streams, num_bits_per_symbol], tf.rank(z) - 1) | ||
|
||
return z | ||
|
||
|
||
class LinearTransformPrecodingDetector(sionna.ofdm.detection.OFDMDetector): | ||
def __init__(self, | ||
equalizer, | ||
output, | ||
demapping_method, | ||
resource_grid, | ||
stream_management, | ||
constellation_type=None, | ||
num_bits_per_symbol=None, | ||
constellation=None, | ||
hard_out=False, | ||
dtype=tf.complex64, | ||
**kwargs): | ||
# Instantiate the linear detector | ||
detector = LinearTransformPrecodingMimoDetector(equalizer=equalizer, | ||
output=output, | ||
demapping_method=demapping_method, | ||
num_subcarriers=resource_grid.num_effective_subcarriers, | ||
constellation_type=constellation_type, | ||
num_bits_per_symbol=num_bits_per_symbol, | ||
constellation=constellation, | ||
hard_out=hard_out, | ||
dtype=dtype, | ||
**kwargs) | ||
|
||
super().__init__(detector=detector, | ||
output=output, | ||
resource_grid=resource_grid, | ||
stream_management=stream_management, | ||
dtype=dtype, | ||
**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import tensorflow as tf | ||
from tensorflow.keras.layers import Layer | ||
|
||
|
||
class PUSCHTransformPrecoder(Layer): | ||
def __init__(self, | ||
num_subcarriers, | ||
dtype=tf.complex64, | ||
**kwargs): | ||
super().__init__(dtype=dtype, **kwargs) | ||
self._num_subcarriers = num_subcarriers | ||
|
||
def call(self, y): | ||
orig_shape = tf.shape(y) | ||
y_reshaped = tf.reshape(y, [-1, self._num_subcarriers]) | ||
y_transformed = tf.cast(tf.sqrt(1 / self._num_subcarriers), self._dtype) * tf.signal.fft(y_reshaped) | ||
y_result = tf.reshape(y_transformed, orig_shape) | ||
return y_result | ||
|
||
|
||
class PUSCHTransformDeprecoder(Layer): | ||
def __init__(self, | ||
num_subcarriers, | ||
dtype=tf.complex64, | ||
**kwargs): | ||
super().__init__(dtype=dtype, **kwargs) | ||
self._num_subcarriers = num_subcarriers | ||
|
||
def call(self, y): | ||
orig_shape = tf.shape(y) | ||
y_reshaped = tf.reshape(y, [-1, self._num_subcarriers]) | ||
y_transformed = tf.cast(tf.sqrt(float(self._num_subcarriers)), self._dtype) * tf.signal.ifft(y_reshaped) | ||
y_result = tf.reshape(y_transformed, orig_shape) | ||
return y_result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.