File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,8 @@ cdef class usm_ndarray:
178
178
cdef Py_ssize_t _offset = offset
179
179
cdef Py_ssize_t ary_min_displacement = 0
180
180
cdef Py_ssize_t ary_max_displacement = 0
181
+ cdef bint is_fp64 = False
182
+ cdef bint is_fp16 = False
181
183
182
184
self ._reset()
183
185
if (not isinstance (shape, (list , tuple ))
@@ -253,6 +255,16 @@ cdef class usm_ndarray:
253
255
self ._cleanup()
254
256
raise ValueError ((" buffer='{}' can not accomodate "
255
257
" the requested array." ).format(buffer ))
258
+ is_fp64 = (typenum == UAR_DOUBLE or typenum == UAR_CDOUBLE)
259
+ is_fp16 = (typenum == UAR_HALF)
260
+ if (is_fp64 or is_fp16):
261
+ if ((is_fp64 and not _buffer.sycl_device.has_aspect_fp64) or
262
+ (is_fp16 and not _buffer.sycl_device.has_aspect_fp16)
263
+ ):
264
+ raise ValueError (
265
+ f" Device {_buffer.sycl_device.name} does"
266
+ f" not support {dtype} natively."
267
+ )
256
268
self .base_ = _buffer
257
269
self .data_ = (< char * > (< size_t> _buffer._pointer)) + itemsize * _offset
258
270
self .shape_ = shape_ptr
You can’t perform that action at this time.
0 commit comments