Skip to content

dpctl.tensor.nonzero returns an incorrect array dtype in dpctl=0.14.6dev1 [win] #1335

Closed

Description

@vlad-perevezentsev

dpctl.tensor.nonzero() in dpctl<=0.14.5 used to return a tuple of arrays with int64 type.
Now in dpctl=0.14.6dev1 nonzero() returns a tuple of arrays with int32 type.
This behavior was found only on windows OS.

# dpctl=0.14.6dev1

import dpctl.tensor as dpt

cond = dpt.asarray([0,1,2,0],dtype='int32')
dpt.nonzero(cond)
> (usm_ndarray([1, 2], dtype=int32),)

cond = dpt.astype(cond, 'int64')
> (usm_ndarray([1, 2, 3], dtype=int32),)

# dpctl 0.14.5

import dpctl.tensor as dpt

cond = dpt.asarray([0,1,2,0],dtype='int32')
dpt.nonzero(cond)
> (usm_ndarray([1, 2]),)
dpt.nonzero(cond)[0].dtype
> dtype('int64')

cond = dpt.astype(cond, 'int64')
dpt.nonzero(cond)[0].dtype
> dtype('int64')

# numpy

import numpy

cond_np = dpt.asnumpy(cond)
numpy.nonzero(cond_np)
> (array([1, 2], dtype=int64),)

Activity

  1. added
    bug
    on Aug 11, 2023
  2. changed the title [-]dpctl.tensort.nonzero returns an incorrect array dtype in dpctl=0.14.6dev1 [win][/-] [+]dpctl.tensor.nonzero returns an incorrect array dtype in dpctl=0.14.6dev1 [win][/+] on Aug 11, 2023
  3. oleksandr-pavlyk commented on Aug 11, 2023

    @oleksandr-pavlyk
    Contributor

    The array API spec for xp.nonzero states:

    The returned array must have the default array index data type.

    I misread this as default integral data type (which is indeed 32-bit on Windows). I will fix this promptly,

  4. added a commit that references this issue on Aug 11, 2023
    bf22a28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions