Skip to content

Commit be3c43e

Browse files
committed
Add warning message if __cuda_stream__ attribute is used
1 parent 049a2f1 commit be3c43e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cuda_core/cuda/core/experimental/_stream.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from __future__ import annotations
66

77
import os
8+
import warnings
89
import weakref
910
from dataclasses import dataclass
1011
from typing import TYPE_CHECKING, Optional, Tuple, Union
@@ -87,12 +88,16 @@ def _init(obj=None, *, options: Optional[StreamOptions] = None):
8788
if obj is not None and options is not None:
8889
raise ValueError("obj and options cannot be both specified")
8990
if obj is not None:
90-
if not hasattr(obj, "__cuda_stream__"):
91-
raise ValueError
9291
try:
9392
info = obj.__cuda_stream__()
9493
except TypeError:
9594
info = obj.__cuda_stream__
95+
warnings.simplefilter("once", DeprecationWarning)
96+
warnings.warn(
97+
"Implementing __cuda_stream__ as an attribute is deprecated; it must be implemented as a method",
98+
category=DeprecationWarning,
99+
)
100+
96101
assert info[0] == 0
97102
self._mnff.handle = cuda.CUstream(info[1])
98103
# TODO: check if obj is created under the current context/device

0 commit comments

Comments
 (0)