File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,13 @@ def _usm_ndarray_from_suai(obj):
202
202
buffer = membuf ,
203
203
strides = sua_iface .get ("strides" , None ),
204
204
)
205
+ _data_field = sua_iface ["data" ]
206
+ if isinstance (_data_field , tuple ) and len (_data_field ) > 1 :
207
+ ro_field = _data_field [1 ]
208
+ else :
209
+ ro_field = False
210
+ if ro_field :
211
+ ary .flags ["W" ] = False
205
212
return ary
206
213
207
214
Original file line number Diff line number Diff line change @@ -2368,3 +2368,29 @@ def test_gh_1201():
2368
2368
c = dpt .flip (dpt .empty (a .shape , dtype = a .dtype ))
2369
2369
c [:] = a
2370
2370
assert (dpt .asnumpy (c ) == a ).all ()
2371
+
2372
+
2373
+ class ObjWithSyclUsmArrayInterface :
2374
+ def __init__ (self , ary ):
2375
+ self ._array_obj = ary
2376
+
2377
+ @property
2378
+ def __sycl_usm_array_interface__ (self ):
2379
+ _suai = self ._array_obj .__sycl_usm_array_interface__
2380
+ return _suai
2381
+
2382
+
2383
+ @pytest .mark .parametrize ("ro_flag" , [True , False ])
2384
+ def test_asarray_writable_flag (ro_flag ):
2385
+ try :
2386
+ a = dpt .empty (8 )
2387
+ except dpctl .SyclDeviceCreationError :
2388
+ pytest .skip ("No SYCL devices available" )
2389
+
2390
+ a .flags ["W" ] = not ro_flag
2391
+ wrapped = ObjWithSyclUsmArrayInterface (a )
2392
+
2393
+ b = dpt .asarray (wrapped )
2394
+
2395
+ assert b .flags ["W" ] == (not ro_flag )
2396
+ assert b ._pointer == a ._pointer
You can’t perform that action at this time.
0 commit comments