From a5e555c7346b3a23c66017c6350aedd9bc7248de Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Wed, 19 Nov 2025 10:45:33 -0800 Subject: [PATCH 1/2] deprecate the dpctl.tensor submodule the submodule will move to dpnp.tensor in a future release --- dpctl/tensor/__init__.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dpctl/tensor/__init__.py b/dpctl/tensor/__init__.py index df10879b68..b542624fcc 100644 --- a/dpctl/tensor/__init__.py +++ b/dpctl/tensor/__init__.py @@ -23,6 +23,9 @@ [ArrayAPI] https://data-apis.org/array-api """ +# import for deprecation warning +import warnings as _warnings + from dpctl.tensor._copy_utils import asnumpy, astype, copy, from_numpy, to_numpy from dpctl.tensor._ctors import ( arange, @@ -208,6 +211,14 @@ from ._testing import allclose from ._type_utils import can_cast, finfo, iinfo, isdtype, result_type +# deprecation warning for the dpctl.tensor module +_warnings.warn( + "dpctl.tensor is deprecated since dpctl 0.21.1 and will be removed in a " + "future release. Install dpnp and use 'import dpnp.tensor' instead.", + DeprecationWarning, + stacklevel=2, +) + __all__ = [ "Device", "usm_ndarray", @@ -397,3 +408,17 @@ "sycl_device_to_dldevice", "isin", ] + + +def __getattr__(name: str): # pragma: no cover + # per-attribute access deprecation notices per PEP 562 + if name in __all__: + _warnings.warn( + f"dpctl.tensor.{name} is deprecated; dpctl.tensor is deprecated " + "since dpctl 0.21.1 and will be removed in a future release. " + "Install dpnp and use 'import dpnp.tensor' instead.", + DeprecationWarning, + stacklevel=2, + ) + return globals()[name] + raise AttributeError(f"module 'dpctl.tensor' has no attribute '{name}'") From 1b7da94f472f349dbe34bf37132c406b4cc4a8c8 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Fri, 21 Nov 2025 08:46:22 -0800 Subject: [PATCH 2/2] clarify deprecation warning --- dpctl/tensor/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dpctl/tensor/__init__.py b/dpctl/tensor/__init__.py index b542624fcc..a5aa18834d 100644 --- a/dpctl/tensor/__init__.py +++ b/dpctl/tensor/__init__.py @@ -214,7 +214,9 @@ # deprecation warning for the dpctl.tensor module _warnings.warn( "dpctl.tensor is deprecated since dpctl 0.21.1 and will be removed in a " - "future release. Install dpnp and use 'import dpnp.tensor' instead.", + "future release. The functionality will be moved to separate package, dpnp " + "(see: https://github.com/IntelPython/dpnp). After that, use " + "'import dpnp.tensor' instead.", DeprecationWarning, stacklevel=2, ) @@ -415,8 +417,10 @@ def __getattr__(name: str): # pragma: no cover if name in __all__: _warnings.warn( f"dpctl.tensor.{name} is deprecated; dpctl.tensor is deprecated " - "since dpctl 0.21.1 and will be removed in a future release. " - "Install dpnp and use 'import dpnp.tensor' instead.", + "since dpctl 0.21.1 and will be removed in a future release. The " + "functionality will be moved to separate package, dpnp (see: " + "https://github.com/IntelPython/dpnp). After that, use 'import " + "dpnp.tensor' instead.", DeprecationWarning, stacklevel=2, )