Skip to content

Using __array_interface__ instead of adding __sycl_usm_array_interface__ #191

Description

@PokhodenkoSA

Using 2 properties __array_interface__ and __sycl_usm_array_interface__ in dparray requires 2 checks in downstream libraries.
Performance penalty.
Related to #184.

/CC @oleksandr-pavlyk @shssf

Activity

  1. changed the title [-]Usgin __array_interface__ instead of adding __sycl_usm_array_interface__[/-] [+]Using __array_interface__ instead of adding __sycl_usm_array_interface__[/+] on Dec 3, 2020
  2. oleksandr-pavlyk commented on Dec 3, 2020

    @oleksandr-pavlyk
    Contributor

    These two properties serve different purposes, and can not be combined. One does not have to check for both. Please clarify what performance penalty you have in mind.

  3. PokhodenkoSA commented on Dec 3, 2020

    @PokhodenkoSA
    ContributorAuthor

    different purposes

    Does it mean that we will always know exactly which property we need?

    Please clarify what performance penalty you have in mind.

    Double checking both properties. One for SYCL queue (__sycl_usm_array_interface__) and another for fallback to usual __array_interface__ if the first property is not available.

  4. PokhodenkoSA commented on Dec 3, 2020

    @PokhodenkoSA
    ContributorAuthor

    I know this cases from dpNP and @shssf.
    Also I have asked @DrTodd13 about this new property.
    Just want to know the reasons behind introducing this property and comparing to other variants (i.e. extend __array_interface__ dict with new items).

  5. oleksandr-pavlyk commented on Dec 3, 2020

    @oleksandr-pavlyk
    Contributor

    NumPy checks for __array_interface__ trying to recognize a Python object as a "duck-array", also known as "array-like" . This property has been largely superseded by Python buffer protocol.

    Python objects backed by USM memory export __sycl_usm_array_interface__ to be recognized as carriers of USM memory.

  6. diptorupd commented on Jan 31, 2021

    @diptorupd
    Contributor

    Closing since @oleksandr-pavlyk's comments explains the rationale of why the two attributes are needed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions