File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,18 @@ def wait(self):
124
124
"""
125
125
self .sycl_queue_ .wait ()
126
126
127
+ def __eq__ (self , other ):
128
+ """Equality comparison based on underlying ``sycl_queue``."""
129
+ if isinstance (other , Device ):
130
+ return self .sycl_queue .__eq__ (other .sycl_queue )
131
+ elif isinstance (other , dpctl .SyclQueue ):
132
+ return self .sycl_queue .__eq__ (other )
133
+ return False
134
+
135
+ def __hash__ (self ):
136
+ """Compute object's hash value."""
137
+ return self .sycl_queue .__hash__ ()
138
+
127
139
128
140
def normalize_queue_device (sycl_queue = None , device = None ):
129
141
"""
Original file line number Diff line number Diff line change @@ -1575,3 +1575,19 @@ def test_asarray_uint64():
1575
1575
Xnp = np .ndarray (1 , dtype = np .uint64 )
1576
1576
X = dpt .asarray (Xnp )
1577
1577
assert X .dtype == Xnp .dtype
1578
+
1579
+
1580
+ def test_Device ():
1581
+ try :
1582
+ dev = dpctl .select_default_device ()
1583
+ d1 = dpt .Device .create_device (dev )
1584
+ d2 = dpt .Device .create_device (dev )
1585
+ except (dpctl .SyclQueueCreationError , dpctl .SyclDeviceCreationError ):
1586
+ pytest .skip (
1587
+ "Could not create default device, or a queue that targets it"
1588
+ )
1589
+ assert d1 == d2
1590
+ dict = {d1 : 1 }
1591
+ assert dict [d2 ] == 1
1592
+ assert d1 == d2 .sycl_queue
1593
+ assert not d1 == Ellipsis
You can’t perform that action at this time.
0 commit comments