Skip to content

dpt.unique_inverse and dpt.unique_all returns inverse_indices array of int32 dtype #1738

Closed
@antonwolfy

Description

@antonwolfy

The issue is quite similar to gh-1322.

The result type of inverse_indices may vary on the same platform:

import dpctl, dpctl.tensor as dpt, numpy

dpctl.__version__
# Out: '0.18.0dev0+80.gb7fd613acc'

a = dpt.ones(10, dtype="i8")

dpt.unique_inverse(a).inverse_indices.dtype
# Out: dtype('int32')

dpt.unique_all(a).inverse_indices.dtype
# Out: dtype('int32')

a = dpt.arange(10, dtype="i8")
dpt.unique_inverse(a).inverse_indices.dtype
# Out: dtype('int64')

dpt.unique_all(a).inverse_indices.dtype
# Out: dtype('int64')

while the specification states:

second element must have the field name inverse_indices and must be an array containing the indices of values that reconstruct x. The array must have the same shape as x and have the default array index data type.

and here is about the default array index type:

a default array index data type (either int32 or int64).
...
The default array index data type may be int32 on 32-bit platforms, but the default should be int64 otherwise.

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