Skip to content

Commit a5e555c

Browse files
committed
deprecate the dpctl.tensor submodule
the submodule will move to dpnp.tensor in a future release
1 parent 878cc19 commit a5e555c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

dpctl/tensor/__init__.py

Lines changed: 25 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,
@@ -208,6 +211,14 @@
208211
from ._testing import allclose
209212
from ._type_utils import can_cast, finfo, iinfo, isdtype, result_type
210213

214+
# deprecation warning for the dpctl.tensor module
215+
_warnings.warn(
216+
"dpctl.tensor is deprecated since dpctl 0.21.1 and will be removed in a "
217+
"future release. Install dpnp and use 'import dpnp.tensor' instead.",
218+
DeprecationWarning,
219+
stacklevel=2,
220+
)
221+
211222
__all__ = [
212223
"Device",
213224
"usm_ndarray",
@@ -397,3 +408,17 @@
397408
"sycl_device_to_dldevice",
398409
"isin",
399410
]
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. "
419+
"Install dpnp and use 'import dpnp.tensor' instead.",
420+
DeprecationWarning,
421+
stacklevel=2,
422+
)
423+
return globals()[name]
424+
raise AttributeError(f"module 'dpctl.tensor' has no attribute '{name}'")

0 commit comments

Comments
 (0)