Skip to content

dpctl.tensor.reshape() accepts reshape of 0-sized array into shape with zero #1197

@antonwolfy

Description

@antonwolfy

An example below raises ValueError exception in NumPy indicating boundary issue, but there is no exception in dpctl and RuntimeWarning regarding divide by zero is issued:

import numpy,  dpctl.tensor as dpt

a = numpy.zeros((0,))
a.reshape((-1, 0))
Out:
...
ValueError: cannot reshape array of size 0 into shape (0)

a = dpt.zeros((0,))
dpt.reshape(a, (-1, 0))
/localdisk/work/antonvol/soft/miniconda3/envs/dpnp_py39_ext/lib/python3.9/site-packages/dpctl/tensor/_reshape.py:126: RuntimeWarning: divide by zero encountered in long_scalars
  v = X.size // (-np.prod(shape))
Out: usm_ndarray([])

Metadata

Metadata

Assignees

No one assigned

    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