Skip to content

Dpctl raises ValueError when changing to larger dtype through the constructor #2119

Open
@antonwolfy

Description

@antonwolfy

Dpctl does not allow to change dtype to larger one thorugh the constructor call for 0-size array:

import dpctl, dpctl.tensor as dpt

dpctl.__version__
# Out: '0.21.0dev0+49.g5be8ef909c'

# create 0-sized array
a = dpt.zeros((0,), dtype='i2')

b = dpt.usm_ndarray((0,), dtype='i1', buffer=a)  # it works
c = dpt.usm_ndarray((0,), dtype='i4', buffer=a)  # it fails
ValueError                                Traceback (most recent call last)
Cell In[9], line 1
----> 1 c = dpt.usm_ndarray((0,), dtype='i4', buffer=a)

File dpctl/tensor/_usmarray.pyx:388, in dpctl.tensor._usmarray.usm_ndarray.__cinit__()

ValueError: buffer='[]' can not accommodate the requested array.

The input array has zero size, so it is expected that it can be casted to any data type.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions