File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -116,8 +116,9 @@ def inner(*args, **kwargs):
116
116
117
117
def get_device_from_ctx (ctx_handle ) -> int :
118
118
"""Get device ID from the given ctx."""
119
- prev_ctx = Device ().context .handle
120
- if ctx_handle != prev_ctx :
119
+ from cuda .core .experimental ._device import Device # avoid circular import
120
+ prev_ctx = Device ().context ._handle
121
+ if int (ctx_handle ) != int (prev_ctx ):
121
122
switch_context = True
122
123
else :
123
124
switch_context = False
Original file line number Diff line number Diff line change @@ -71,6 +71,16 @@ def test_stream_context():
71
71
context = stream .context
72
72
assert context is not None
73
73
74
+ def test_stream_from_foreign_stream ():
75
+ device = Device ()
76
+ other_stream = device .create_stream (options = StreamOptions ())
77
+ stream = device .create_stream (obj = other_stream )
78
+ assert other_stream .handle == stream .handle
79
+ device = stream .device
80
+ assert isinstance (device , Device )
81
+ context = stream .context
82
+ assert context is not None
83
+
74
84
def test_stream_from_handle ():
75
85
stream = Stream .from_handle (0 )
76
86
assert isinstance (stream , Stream )
You can’t perform that action at this time.
0 commit comments