Skip to content

Commit 3084831

Browse files
authored
Merge pull request #2199 from IntelPython/backport-gh-2191
Backport gh-2191
2 parents 99c7e90 + 96aed3d commit 3084831

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

dpctl/tensor/__init__.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
[ArrayAPI] https://data-apis.org/array-api
2424
"""
2525

26+
# import for deprecation warning
27+
import warnings as _warnings
28+
2629
from dpctl.tensor._copy_utils import asnumpy, astype, copy, from_numpy, to_numpy
2730
from dpctl.tensor._ctors import (
2831
arange,
@@ -207,6 +210,16 @@
207210
from ._testing import allclose
208211
from ._type_utils import can_cast, finfo, iinfo, isdtype, result_type
209212

213+
# deprecation warning for the dpctl.tensor module
214+
_warnings.warn(
215+
"dpctl.tensor is deprecated since dpctl 0.21.1 and will be removed in a "
216+
"future release. The functionality will be moved to separate package, dpnp "
217+
"(see: https://github.com/IntelPython/dpnp). After that, use "
218+
"'import dpnp.tensor' instead.",
219+
DeprecationWarning,
220+
stacklevel=2,
221+
)
222+
210223
__all__ = [
211224
"Device",
212225
"usm_ndarray",
@@ -395,3 +408,19 @@
395408
"dldevice_to_sycl_device",
396409
"sycl_device_to_dldevice",
397410
]
411+
412+
413+
def __getattr__(name: str): # pragma: no cover
414+
# per-attribute access deprecation notices per PEP 562
415+
if name in __all__:
416+
_warnings.warn(
417+
f"dpctl.tensor.{name} is deprecated; dpctl.tensor is deprecated "
418+
"since dpctl 0.21.1 and will be removed in a future release. The "
419+
"functionality will be moved to separate package, dpnp (see: "
420+
"https://github.com/IntelPython/dpnp). After that, use 'import "
421+
"dpnp.tensor' instead.",
422+
DeprecationWarning,
423+
stacklevel=2,
424+
)
425+
return globals()[name]
426+
raise AttributeError(f"module 'dpctl.tensor' has no attribute '{name}'")

0 commit comments

Comments
 (0)