Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

less_equal returns incorrect result #1251

Open
antonwolfy opened this issue Jun 15, 2023 · 2 comments
Open

less_equal returns incorrect result #1251

antonwolfy opened this issue Jun 15, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@antonwolfy
Copy link
Collaborator

The code below works incorrectly in dpctl:

import numpy, dpctl, dpctl.tensor as dpt

dpt.less_equal(dpt.asarray(2, dtype=numpy.int32), numpy.iinfo(numpy.uint32).max)
Out: usm_ndarray(False)

numpy.less_equal(numpy.asarray(2, dtype=numpy.int32), numpy.iinfo(numpy.uint32).max)
Out: True

It looks like dpctl always casts a scalar to the same type as incoming usm_ndarray has, which might cause wrong result.

@ndgrigorian
Copy link
Collaborator

ndgrigorian commented Jun 15, 2023

According to NEP-50, which has been the guideline for our binary operation type promotion, this case should probably raise an exception, since it's a Python scalar that's too large for the array type.

@ndgrigorian ndgrigorian self-assigned this Apr 29, 2024
@ndgrigorian
Copy link
Collaborator

According to NEP-50, which has been the guideline for our binary operation type promotion, this case should probably raise an exception, since it's a Python scalar that's too large for the array type.

There have been developments in this since last year! NEP-50 has been clarified to focus on result types, so Numpy 2 now permits (and correctly calculates) this edge case.

Enhancements to dpctl will be made to support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants