Skip to content

Incorrect behavior of order parameter for order="K" #1326

Closed

Description

@ndgrigorian

As has been picked up by the array API test suite, the order="K" parameter does not work in some cases:

In [1]: import dpctl.tensor._usmarray as ua, dpctl.tensor as dpt

In [2]: x = dpt.usm_ndarray((1, 1, 2, 1, 1), dpt.bool, (0, 0, 1, 0, 0))

In [3]: dpt.astype(x, dpt.bool, order="K")

this raises
ValueError: buffer='<SYCL(TM) USM-device allocation of 2 bytes at 0xffffb80200010200>' can not accomodate the requested array.
because the logic calculating the strides is incorrect in this case.

dpt.copy raises the same error for the same array

The internal function _empty_like_orderK does better

In [3]: x = dpt.usm_ndarray((1, 1, 2, 1, 1), dpt.bool, (0, 0, 1, 0, 0))

In [4]: _empty_like_orderK(x, dpt.bool)
Out[4]:
usm_ndarray([[[[[False]],

               [[False]]]]])

but it's worth noting that the output of the strides are (1, 1, 1, 1, 1) where for Numpy they are (2, 2, 1, 1, 1).

This behavior should be implemented identically everywhere order="K" appears in dpctl.

Activity

  1. oleksandr-pavlyk commented on Aug 9, 2023

    @oleksandr-pavlyk
    Contributor

    This is being fixed in gh-1324

  2. ndgrigorian commented on Aug 9, 2023

    @ndgrigorian
    CollaboratorAuthor

    Resolved by #1324

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions