Skip to content

dpctl.tensor.reshape raises ValueError with empty list as input #729

Closed

Description

@LukichevaPolina

Reproduces:

import dpctl.tensor as dpt

a = dpt.asarray([])
dpt.reshape(a, (0,))

Output:

Traceback (most recent call last):
  File "/localdisk/work/plukiche/dpnp_fork/dpctl_empty_reshape_repro.py", line 4, in <module>
    dpt.reshape(a, (0,))
  File "/localdisk/work/plukiche/miniconda/miniconda3/envs/dpnptc4_internal/lib/python3.8/site-packages/dpctl/tensor/_reshape.py", line 107, in reshape
    newsts = reshaped_strides(X.shape, X.strides, newshape, order=order)
  File "/localdisk/work/plukiche/miniconda/miniconda3/envs/dpnptc4_internal/lib/python3.8/site-packages/dpctl/tensor/_reshape.py", line 50, in reshaped_strides
    for flat_index in [
  File "/localdisk/work/plukiche/miniconda/miniconda3/envs/dpnptc4_internal/lib/python3.8/site-packages/dpctl/tensor/_reshape.py", line 51, in <listcomp>
    np.ravel_multi_index(unitvec, new_sh, order=order)
  File "<__array_function__ internals>", line 5, in ravel_multi_index
ValueError: cannot unravel if shape has zero entries (is empty).

dpctl version is 0.12.0dev1+104.gccd21b68

Activity

  1. LukichevaPolina commented on Jan 13, 2022

    @LukichevaPolina
    Author

    @oleksandr-pavlyk, Could you please look at this problem?

  2. self-assigned this
    on Jan 20, 2022
  3. densmirn commented on Jan 21, 2022

    @densmirn
    Contributor

    @oleksandr-pavlyk, could you please either leave a comment or prepare a fix on this issue? The issue is blocking DPNP testing in external CI.

  4. oleksandr-pavlyk commented on Feb 1, 2022

    @oleksandr-pavlyk
    Contributor

    The immediate error is caused by attempting to use np.ravel_multi_index for shape with zero elements. That case should be handled separately.

  5. added a commit that references this issue on Feb 1, 2022
    3048f3e
  6. added a commit that references this issue on Feb 1, 2022
  7. added a commit that references this issue on Feb 3, 2022
    13ce295
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions