From 127620ba6a4dda3ea1c371533cc9e22815223576 Mon Sep 17 00:00:00 2001 From: mrava87 Date: Sat, 26 Oct 2024 13:05:49 +0300 Subject: [PATCH 1/2] bug: fix problem in Restriction when passing iava as cupy array --- pylops/basicoperators/restriction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylops/basicoperators/restriction.py b/pylops/basicoperators/restriction.py index 2595c971..362d82de 100644 --- a/pylops/basicoperators/restriction.py +++ b/pylops/basicoperators/restriction.py @@ -13,6 +13,7 @@ get_normalize_axis_index, inplace_set, to_cupy_conditional, + to_numpy, ) from pylops.utils.typing import DTypeLike, InputDimsLike, IntNDArray, NDArray @@ -146,7 +147,7 @@ def __init__( # explicitly create a list of indices in the n-dimensional # model space which will be used in _rmatvec to place the input if ncp != np: - self.iavamask = _compute_iavamask(self.dims, axis, iava, ncp) + self.iavamask = _compute_iavamask(self.dims, axis, to_numpy(iava), ncp) self.inplace = inplace self.axis = axis self.iavareshape = iavareshape @@ -173,7 +174,6 @@ def _rmatvec(self, x: NDArray) -> NDArray: ) else: if not hasattr(self, "iavamask"): - self.iava = to_cupy_conditional(x, self.iava) self.iavamask = _compute_iavamask(self.dims, self.axis, self.iava, ncp) y = ncp.zeros(int(self.shape[-1]), dtype=self.dtype) y = inplace_set(x.ravel(), y, self.iavamask) From 71dc191ef0f3c1fe56d055e30e38dfba9a868da6 Mon Sep 17 00:00:00 2001 From: mrava87 Date: Sat, 26 Oct 2024 14:33:34 +0300 Subject: [PATCH 2/2] minor: removed unused import --- pylops/basicoperators/restriction.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pylops/basicoperators/restriction.py b/pylops/basicoperators/restriction.py index 362d82de..c2fceab7 100644 --- a/pylops/basicoperators/restriction.py +++ b/pylops/basicoperators/restriction.py @@ -12,7 +12,6 @@ get_array_module, get_normalize_axis_index, inplace_set, - to_cupy_conditional, to_numpy, ) from pylops.utils.typing import DTypeLike, InputDimsLike, IntNDArray, NDArray