Skip to content

Commit

Permalink
CI: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Oct 6, 2023
1 parent 03c79d6 commit f431920
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pipeline {
}
environment {
HOME = "$WORKSPACE"
PYBIN = "/opt/python/cp38-cp38/bin"
PYBIN = "/opt/python/cp39-cp39/bin"
LIBRARY_PATH = "$WORKSPACE/finufft/build"
LD_LIBRARY_PATH = "$WORKSPACE/finufft/build"
}
Expand All @@ -42,6 +42,7 @@ pipeline {
cuda_arch="70"
cmake -B build . -DFINUFFT_USE_CUDA=ON \
-DFINUFFT_USE_CPU=OFF \
-DFINUFFT_BUILD_TESTS=OFF \
-DCMAKE_CUDA_ARCHITECTURES="$cuda_arch" \
-DBUILD_TESTING=ON
Expand All @@ -56,11 +57,10 @@ pipeline {
# we could also move pytorch install inside docker
python3 -m pip install "torch~=2.1.0" --index-url https://download.pytorch.org/whl/cu118
python3 -m pip install finufft/python/cufinufft
python3 -m pip install finufft/python/finufft
python3 -m pip install -e .[dev]
python3 -m pytest -k "cuda" tests/ --cov
python3 -m pytest -k "cuda" tests/ --cov -v
'''
}
}
Expand Down
42 changes: 27 additions & 15 deletions pytorch_finufft/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,28 @@

from typing import Any, Dict, Optional, Tuple, Union

import finufft
import numpy as np
import torch

try:
import finufft

FINUFFT_AVAIL = True
except ImportError:
FINUFFT_AVAIL = False

try:
import cufinufft

CUFINUFFT_AVAIL = True
except ImportError:
CUFINUFFT_AVAIL = False
import torch

if not (FINUFFT_AVAIL or CUFINUFFT_AVAIL):
raise ImportError(
"No FINUFFT implementation available. "
"Install either finufft or cufinufft and ensure they are importable."
)

import pytorch_finufft._err as err

Expand Down Expand Up @@ -1631,7 +1643,7 @@ def forward(
ctx: Any,
points: torch.Tensor,
values: torch.Tensor,
output_shape: Union[int, tuple[int, int], tuple[int, int, int]],
output_shape: Union[int, Tuple[int, int], Tuple[int, int, int]],
out: Optional[torch.Tensor] = None,
fftshift: bool = False,
finufftkwargs: dict[str, Union[int, float]] = None,
Expand Down Expand Up @@ -1693,21 +1705,21 @@ def forward(
@staticmethod
def backward(
ctx: Any, grad_output: torch.Tensor
) -> tuple[Union[torch.Tensor, None], ...]:
) -> Tuple[Union[torch.Tensor, None], ...]:
"""
Implements derivatives wrt. each argument in the forward method.
Implements derivatives wrt. each argument in the forward method.
Parameters
----------
ctx : Any
Pytorch context object.
grad_output : torch.Tensor
Backpass gradient output
Parameters
----------
ctx : Any
Pytorch context object.
grad_output : torch.Tensor
Backpass gradient output
Returns
-------
tuple[Union[torch.Tensor, None], ...]
A tuple of derivatives wrt. each argument in the forward method
Returns
-------
Tuple[Union[torch.Tensor, None], ...]
A tuple of derivatives wrt. each argument in the forward method
"""
_i_sign = -1 * ctx.isign
_mode_ordering = ctx.mode_ordering
Expand Down

0 comments on commit f431920

Please sign in to comment.