Skip to content

dpctl.tensor.astype raises ValueError with empty list as input #728

Closed

Description

@LukichevaPolina

Reproducer:

import dpctl.tensor as dpt

a = dpt.asarray([])
dpt.astype(a, float)

Output:

Traceback (most recent call last):
  File "/localdisk/work/plukiche/dpnp_fork/dpctl_empty_astype_repro.py", line 4, in <module>
    dpt.astype(a, float)
  File "/localdisk/work/plukiche/miniconda/miniconda3/envs/dpnptc4_internal/lib/python3.8/site-packages/dpctl/tensor/_copy_utils.py", line 447, in astype
    _copy_from_usm_ndarray_to_usm_ndarray(R, usm_ary)
  File "/localdisk/work/plukiche/miniconda/miniconda3/envs/dpnptc4_internal/lib/python3.8/site-packages/dpctl/tensor/_copy_utils.py", line 282, in _copy_from_usm_ndarray_to_usm_ndarray
    copy_same_shape(dst, src)
  File "/localdisk/work/plukiche/miniconda/miniconda3/envs/dpnptc4_internal/lib/python3.8/site-packages/dpctl/tensor/_copy_utils.py", line 239, in copy_same_shape
    copy_same_dtype(dst, src)
  File "/localdisk/work/plukiche/miniconda/miniconda3/envs/dpnptc4_internal/lib/python3.8/site-packages/dpctl/tensor/_copy_utils.py", line 197, in copy_same_dtype
    if _has_memory_overlap(dst, src):
  File "/localdisk/work/plukiche/miniconda/miniconda3/envs/dpnptc4_internal/lib/python3.8/site-packages/dpctl/tensor/_copy_utils.py", line 69, in _has_memory_overlap
    m1 = dpm.as_usm_memory(x1)
  File "dpctl/memory/_memory.pyx", line 736, in dpctl.memory._memory.as_usm_memory
  File "dpctl/memory/_memory.pyx", line 203, in dpctl.memory._memory._Memory._cinit_other
  File "dpctl/memory/_sycl_usm_array_interface_utils.pxi", line 185, in dpctl.memory._memory._USMBufferData.from_sycl_usm_ary_iface
  File "dpctl/memory/_sycl_usm_array_interface_utils.pxi", line 83, in dpctl.memory._memory._pointers_from_shape_and_stride
ValueError: Array shape elements need to be positive

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. 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.

  3. oleksandr-pavlyk commented on Feb 1, 2022

    @oleksandr-pavlyk
    Contributor

    The issue is with the logic of copying:

    In [5]: import dpctl.tensor as dpt
       ...:
       ...: a = dpt.asarray([])
    
    In [6]: b = dpt.asarray([], 'd')
    
    In [7]: b[...] = a
    ---------------------------------------------------------------------------
    ValueError                                Traceback (most recent call last)
    
  4. added 4 commits that reference this issue on Feb 1, 2022
    6c65231
    f04fe06
    624564e
    3ce1b68
  5. added a commit that references this issue on Feb 1, 2022
  6. added 2 commits that reference this issue on Feb 3, 2022
    d4a899b
    ba39465
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