@@ -34,6 +34,7 @@ from cpython.bytes cimport PyBytes_AS_STRING, PyBytes_FromStringAndSize
34
34
from cpython cimport pycapsule
35
35
36
36
import numpy as np
37
+ import numbers
37
38
38
39
__all__ = [
39
40
" MemoryUSMShared" ,
@@ -51,21 +52,21 @@ cdef DPCTLSyclQueueRef _queue_ref_copy_from_SyclQueue(SyclQueue q):
51
52
52
53
cdef DPCTLSyclQueueRef _queue_ref_copy_from_USMRef_and_SyclContext(
53
54
DPCTLSyclUSMRef ptr, SyclContext ctx):
54
- """ Obtain device from pointer and sycl context, use
55
+ """ Obtain device from pointer and sycl context, use
55
56
context and device to create a queue from which this memory
56
57
can be accessible.
57
58
"""
58
59
cdef SyclDevice dev = _Memory.get_pointer_device(ptr, ctx)
59
60
cdef DPCTLSyclContextRef CRef = NULL
60
- cdef DPCTLSyclDeviceRef DRef = NULL
61
+ cdef DPCTLSyclDeviceRef DRef = NULL
61
62
CRef = ctx.get_context_ref()
62
63
DRef = dev.get_device_ref()
63
64
return DPCTLQueue_Create(CRef, DRef, NULL , 0 )
64
65
65
66
66
67
cdef DPCTLSyclQueueRef get_queue_ref_from_ptr_and_syclobj(
67
68
DPCTLSyclUSMRef ptr, object syclobj):
68
- """ Constructs queue from pointer and syclobject from
69
+ """ Constructs queue from pointer and syclobject from
69
70
__sycl_usm_array_interface__
70
71
"""
71
72
cdef DPCTLSyclQueueRef QRef = NULL
@@ -96,7 +97,7 @@ cdef DPCTLSyclQueueRef get_queue_ref_from_ptr_and_syclobj(
96
97
return QRef
97
98
else :
98
99
return QRef
99
-
100
+
100
101
101
102
cdef void copy_via_host(void * dest_ptr, SyclQueue dest_queue,
102
103
void * src_ptr, SyclQueue src_queue, size_t nbytes):
@@ -207,6 +208,9 @@ def _to_memory(unsigned char [::1] b, str usm_kind):
207
208
208
209
209
210
cdef class _Memory:
211
+ """ Internal class implementing methods common to
212
+ MemoryUSMShared, MemoryUSMDevice, MemoryUSMHost
213
+ """
210
214
cdef _cinit_empty(self ):
211
215
self .memory_ptr = NULL
212
216
self .nbytes = 0
@@ -500,7 +504,7 @@ cdef class MemoryUSMShared(_Memory):
500
504
than 'shared'.
501
505
"""
502
506
def __cinit__ (self , other , *, Py_ssize_t alignment = 0 , SyclQueue queue = None , int copy = False ):
503
- if (isinstance (other, int )):
507
+ if (isinstance (other, numbers.Integral )):
504
508
self ._cinit_alloc(alignment, < Py_ssize_t> other, b" shared" , queue)
505
509
else :
506
510
self ._cinit_other(other)
@@ -532,7 +536,7 @@ cdef class MemoryUSMHost(_Memory):
532
536
than 'host'.
533
537
"""
534
538
def __cinit__ (self , other , *, Py_ssize_t alignment = 0 , SyclQueue queue = None , int copy = False ):
535
- if (isinstance (other, int )):
539
+ if (isinstance (other, numbers.Integral )):
536
540
self ._cinit_alloc(alignment, < Py_ssize_t> other, b" host" , queue)
537
541
else :
538
542
self ._cinit_other(other)
@@ -564,7 +568,7 @@ cdef class MemoryUSMDevice(_Memory):
564
568
than 'device'.
565
569
"""
566
570
def __cinit__ (self , other , *, Py_ssize_t alignment = 0 , SyclQueue queue = None , int copy = False ):
567
- if (isinstance (other, int )):
571
+ if (isinstance (other, numbers.Integral )):
568
572
self ._cinit_alloc(alignment, < Py_ssize_t> other, b" device" , queue)
569
573
else :
570
574
self ._cinit_other(other)
0 commit comments