Skip to content

dpt.astype behaves differently on Windows depending on type of input array #2882

@antonwolfy

Description

@antonwolfy

There is a suspicious behavior I faced on Windows (LNL with fp64 support for GPU):

import dpctl, dpctl.tensor as dpt, numpy as np

dpctl.__version__
# Out: '0.22.0dev0+117.g7960513f68'

# for integer input the result is expected
a = dpt.asarray([160, 120])
dpt.astype(a, dpt.uint8)
# Out: usm_ndarray([160, 120], dtype=uint8)

# for float32 the result seems incorrect:
a = dpt.asarray([160., 120.], dtype='f4')
dpt.astype(a, dpt.uint8)
# Out: usm_ndarray([127, 120], dtype=uint8)

# but with float64 works as expected:
a = dpt.asarray([160., 120.], dtype='f8')
dpt.astype(a, dpt.uint8)
# Out: usm_ndarray([160, 120], dtype=uint8)

# NumPy returns the same result in both cases:

a = np.asarray([160, 120])
np.astype(a, dpt.uint8)
# Out: array([160, 120], dtype=uint8)

a = np.asarray([160., 120.], dtype='f4')
np.astype(a, dpt.uint8)
# Out: array([160, 120], dtype=uint8)

# for CPU device the result is the same as for NumPy:

a = dpt.asarray([160., 120.], dtype='i4', device='cpu')
dpt.astype(a, dpt.uint8)
# Out: usm_ndarray([160, 120], dtype=uint8)

I wonder if there is any limitation for float32 dtype or an issue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions