Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated for tf >= 2.9 #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tensorflow>=2.1.0
numpy
tensorflow>=2.9.0
numpy <2.0
scipy
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ def load_requirements(path_dir=HERE, comment_char='#'):
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.9',
],
)
4 changes: 2 additions & 2 deletions tfkbnufft/kbnufft.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _extract_nufft_interpob(self):
return interpob

def kbnufft_forward(interpob, multiprocessing=False):
@tf.function(experimental_relax_shapes=True)
@tf.function(reduce_retracing=True)
@tf.custom_gradient
def kbnufft_forward_for_interpob(x, om):
"""Apply FFT and interpolate from gridded data to scattered data.
Expand Down Expand Up @@ -207,7 +207,7 @@ def grad(dy):
return kbnufft_forward_for_interpob

def kbnufft_adjoint(interpob, multiprocessing=False):
@tf.function(experimental_relax_shapes=True)
@tf.function(reduce_retracing=True)
@tf.custom_gradient
def kbnufft_adjoint_for_interpob(y, om):
"""Interpolate from scattered data to gridded data and then iFFT.
Expand Down
12 changes: 6 additions & 6 deletions tfkbnufft/nufft/interp_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def calc_coef_and_indices(tm, kofflist, Jval, table, centers, L, dims, conjcoef=

return coef, arr_ind

@tf.function(experimental_relax_shapes=True)
@tf.function(reduce_retracing=True)
def run_interp(griddat, tm, params):
"""Interpolates griddat to off-grid coordinates with input sparse matrices.

Expand Down Expand Up @@ -107,7 +107,7 @@ def run_interp(griddat, tm, params):

return kdat

@tf.function(experimental_relax_shapes=True)
@tf.function(reduce_retracing=True)
def run_interp_back(kdat, tm, params):
"""Interpolates kdat to on-grid coordinates.

Expand Down Expand Up @@ -163,7 +163,7 @@ def run_interp_back(kdat, tm, params):
griddat = tf.transpose(tf.complex(griddat_real, griddat_imag))
return griddat

@tf.function(experimental_relax_shapes=True)
@tf.function(reduce_retracing=True)
def kbinterp(x, om, interpob, conj=False):
"""Apply table interpolation.

Expand Down Expand Up @@ -219,11 +219,11 @@ def _map_body(inputs):
y = y_not_shifted * shift
return y

y = tf.map_fn(_map_body, [x, tm, om], dtype=x.dtype)
y = tf.map_fn(_map_body, [x, tm, om], fn_output_signature=x.dtype)

return y

@tf.function(experimental_relax_shapes=True)
@tf.function(reduce_retracing=True)
def adjkbinterp(y, om, interpob):
"""Apply table interpolation adjoint.

Expand Down Expand Up @@ -272,7 +272,7 @@ def _map_body(inputs):
x = run_interp_back(y_shifted, _tm, params)
return x

x = tf.map_fn(_map_body, [y, om, tm], dtype=y.dtype)
x = tf.map_fn(_map_body, [y, om, tm], fn_output_signature=y.dtype)

bsize = tf.shape(y)[0]
ncoil = tf.shape(y)[1]
Expand Down