Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Copy usm_ndarray fails with order='K' #1350

Copy link
Copy link
@antonwolfy

Description

@antonwolfy
Issue body actions

Below example is not working when both copy=True and order='K' are passed to dpt.asarray:

a = dpt.ones((2, 4, 3))
b = dpt.permute_dims(a, (2, 0, 1))
c = dpt.asarray(b, copy=True, order='K')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[31], line 1
----> 1 c = dpt.asarray(b, copy=True, order='K')

File ~/miniconda3/envs/dpnp_dev/lib/python3.9/site-packages/dpctl/tensor/_ctors.py:580, in asarray(obj, dtype, device, copy, usm_type, sycl_queue, order)
    578 # handle instance(obj, usm_ndarray)
    579 if isinstance(obj, dpt.usm_ndarray):
--> 580     return _asarray_from_usm_ndarray(
    581         obj,
    582         dtype=dtype,
    583         copy=copy,
    584         usm_type=usm_type,
    585         sycl_queue=sycl_queue,
    586         order=order,
    587     )
    588 if hasattr(obj, "__sycl_usm_array_interface__"):
    589     ary = _usm_ndarray_from_suai(obj)

File ~/miniconda3/envs/dpnp_dev/lib/python3.9/site-packages/dpctl/tensor/_ctors.py:198, in _asarray_from_usm_ndarray(usm_ndary, dtype, copy, usm_type, sycl_queue, order)
    196 eq = dpctl.utils.get_execution_queue([usm_ndary.sycl_queue, copy_q])
    197 if eq is not None:
--> 198     hev, _ = ti._copy_usm_ndarray_into_usm_ndarray(
    199         src=usm_ndary, dst=res, sycl_queue=eq
    200     )
    201     hev.wait()
    202 else:

ValueError: Destination array can not accomodate all the elements of source array.

# while with copy=False or order='C' all works fine:
c = dpt.asarray(b, copy=False, order='K')
c is b
# Out: True

c = dpt.asarray(b, copy=True, order='C')
c.flags.c_contiguous
# Out: True

dpctl.__version__
# Out: '0.14.6dev3+4.g9afdb5802'
Reactions are currently unavailable

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.