Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@antonwolfy

Description

@antonwolfy
Issue body actions

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.

Reactions are currently unavailable

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.