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

Add Python scalar support to dpt.where #1719

Merged
merged 3 commits into from
Jul 2, 2024
Merged

Conversation

ndgrigorian
Copy link
Collaborator

This PR proposes a change to dpt.where to add support for Python scalars, aligning it with clip and elementwise functions.

As has been pointed out by the array API community, an common use-case for dpt.where is supporting Python scalars. If the decision to permit them in other elementwise functions is made, where will likely follow suit.

Regardless of the outcome of this decision, it's sensible to support them here.

As the first argument (condition) does not participate in the type promotion in where, if both arguments are scalars, the scalars are treated as the default types for the respective kind.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • If this PR is a work in progress, are you opening the PR as a draft?

`x1` and `x2` can now both be Python scalars. As `condition` has no impact on the data type of the result, when both are scalars, the default data type for the scalar kind is used.
Copy link

github-actions bot commented Jun 26, 2024

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

Copy link

Array API standard conformance tests for dpctl=0.18.0dev0=py310h15de555_80 ran successfully.
Passed: 894
Failed: 15
Skipped: 105

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 87.965% (-0.09%) from 88.057%
when pulling 20929be on support-scalars-in-where
into 26d34f5 on master.

Copy link

Array API standard conformance tests for dpctl=0.18.0dev0=py310h15de555_81 ran successfully.
Passed: 894
Failed: 15
Skipped: 105

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 87.965% (-0.09%) from 88.057%
when pulling 9f449d1 on support-scalars-in-where
into 26d34f5 on master.

Copy link
Collaborator

@antonwolfy antonwolfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the PR in dpnp tests and all tests are passed on GPU and CPU devices.

@ndgrigorian
Copy link
Collaborator Author

CI failure is unrelated to this PR, I will go ahead and merge it

@ndgrigorian ndgrigorian merged commit 12e024d into master Jul 2, 2024
67 of 71 checks passed
@ndgrigorian ndgrigorian deleted the support-scalars-in-where branch July 2, 2024 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants