diff --git a/docs/source/api/index.rst b/docs/source/api/index.rst index c11548f2..7e29fe44 100755 --- a/docs/source/api/index.rst +++ b/docs/source/api/index.rst @@ -62,8 +62,8 @@ Basic operators Real Imag Conj - ToCupy - + + Smoothing and derivatives ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pylops/basicoperators/__init__.py b/pylops/basicoperators/__init__.py index 0014715a..04b6a6a9 100755 --- a/pylops/basicoperators/__init__.py +++ b/pylops/basicoperators/__init__.py @@ -38,7 +38,6 @@ Gradient Gradient. FirstDirectionalDerivative First Directional derivative. SecondDirectionalDerivative Second Directional derivative. - ToCupy Convert to CuPy. """ @@ -74,7 +73,6 @@ from .laplacian import * from .gradient import * from .directionalderivative import * -from .tocupy import * __all__ = [ @@ -111,5 +109,4 @@ "Gradient", "FirstDirectionalDerivative", "SecondDirectionalDerivative", - "ToCupy", ] diff --git a/pylops/basicoperators/tocupy.py b/pylops/basicoperators/tocupy.py deleted file mode 100644 index 8a3a7c6b..00000000 --- a/pylops/basicoperators/tocupy.py +++ /dev/null @@ -1,60 +0,0 @@ -__all__ = ["ToCupy"] - -from typing import Union - -import numpy as np - -from pylops import LinearOperator -from pylops.utils._internal import _value_or_sized_to_tuple -from pylops.utils.backend import to_cupy, to_numpy -from pylops.utils.typing import DTypeLike, InputDimsLike, NDArray - - -class ToCupy(LinearOperator): - r"""Convert to CuPy. - - Convert an input array to CuPy in forward mode, - and convert back to NumPy in adjoint mode. - - Parameters - ---------- - dims : :obj:`list` or :obj:`int` - Number of samples for each dimension - dtype : :obj:`str`, optional - Type of elements in input array. - name : :obj:`str`, optional - Name of operator (to be used by :func:`pylops.utils.describe.describe`) - - Attributes - ---------- - shape : :obj:`tuple` - Operator shape - explicit : :obj:`bool` - Operator contains a matrix that can be solved explicitly - (``True``) or not (``False``) - - Notes - ----- - The ToCupy operator is a special operator that does not perform - any transformation on the input arrays other than converting - them from NumPy to CuPy. This operator can be used when one - is interested to create a chain of operators where only one - (or some of them) act on CuPy arrays, whilst other operate - on NumPy arrays. - - """ - - def __init__( - self, - dims: Union[int, InputDimsLike], - dtype: DTypeLike = "float64", - name: str = "C", - ) -> None: - dims = _value_or_sized_to_tuple(dims) - super().__init__(dtype=np.dtype(dtype), dims=dims, dimsd=dims, name=name) - - def _matvec(self, x: NDArray) -> NDArray: - return to_cupy(x) - - def _rmatvec(self, x: NDArray) -> NDArray: - return to_numpy(x)