Skip to content

Support dpctl.asarray() #640

Closed
Closed

Description

@PokhodenkoSA

Please make dpctl to support asarray() function which converts containers with __sycl_usm_array_interface__ to dpctl native container.

Activity

  1. oleksandr-pavlyk commented on Oct 26, 2021

    @oleksandr-pavlyk
    Contributor

    It needs to be in the same namespace as the usm_ndarray, i.e. dpctl.tensor.asarray.

  2. added a commit that references this issue on Nov 3, 2021
  3. oleksandr-pavlyk commented on Nov 19, 2021

    @oleksandr-pavlyk
    Contributor

    Specs for asarray:

    With #646, the dpctl.tensor.asarray has the following signature:

    dpctl.tensor.asarray(obj, dtype=None, copy=None, order="C", device=None, usm_type=None, sycl_queue=None)

    The obj is an object to be converted to an array. asarray supports:

    • an instance of dpctl.tensor.usm_ndarray
    • an object with __sycl_usm_array_interface__
    • an instance of numpy.ndarray
    • Python scalar, a (possibly nested) sequence of Python scalars
    • an object supporting Python buffer protocol

    N.B.: presently sequences of usm_ndarray objects are not supported, nor are sequences mixing objects with SYCL allocations and objects with host allocations.

    obj that does not fall into any of the above categories, but implements __dlpack__ protocol could be imported with dpctl.tensor.from_dlpack function (array-API spec).

    device and sycl_queue keywords are exclusive (use one or another) unless they represent the same queue.

    device keyword can be None, a valid filter selector string, non-partitioned dpctl.SyclDevice, or dpctl.SyclQueue instance, or the object output by usm_ary.device.

    sycl_queue can be either None, or instance of dpctl.SyclQueue. In the case when device=None and sycl_queue=None, array will be created on device selected by SYCL's default_selector.

    usm_type can be None, "device", "shared", or "host". usm_type=None is understood as keep the usm_type in case when obj is an instance of usm_ndarray, or has __sycl_usm_array_interface__, or use usm_type="device" otherwise.

  4. PokhodenkoSA commented on Nov 21, 2021

    @PokhodenkoSA
    ContributorAuthor

    @oleksandr-pavlyk
    Thank you for the description.
    I will integrate it in numba-dppy (IntelPython/numba-dpex#634).
    It looks like a documentation. Is it a part of documentation already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions