Skip to content

Commit 0865758

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

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,
@@ -207,6 +210,14 @@
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. Install dpnp and use 'import dpnp.tensor' instead.",
217+
DeprecationWarning,
218+
stacklevel=2,
219+
)
220+
210221
__all__ = [
211222
"Device",
212223
"usm_ndarray",
@@ -395,3 +406,17 @@
395406
"dldevice_to_sycl_device",
396407
"sycl_device_to_dldevice",
397408
]
409+
410+
411+
def __getattr__(name: str): # pragma: no cover
412+
# per-attribute access deprecation notices per PEP 562
413+
if name in __all__:
414+
_warnings.warn(
415+
f"dpctl.tensor.{name} is deprecated; dpctl.tensor is deprecated "
416+
"since dpctl 0.21.1 and will be removed in a future release. "
417+
"Install dpnp and use 'import dpnp.tensor' instead.",
418+
DeprecationWarning,
419+
stacklevel=2,
420+
)
421+
return globals()[name]
422+
raise AttributeError(f"module 'dpctl.tensor' has no attribute '{name}'")

0 commit comments

Comments
 (0)