Skip to content

dpctl.tensor.floor_divide fixed for signed 0 output #1271

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

Merged
merged 2 commits into from
Jul 30, 2023

Conversation

ndgrigorian
Copy link
Collaborator

@ndgrigorian ndgrigorian commented Jun 30, 2023

On some devices, sycl::floor and std::floor would drop the sign of 0.

This PR resolves those cases and adds a test.

  • 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?

@github-actions
Copy link

@coveralls
Copy link
Collaborator

coveralls commented Jun 30, 2023

Coverage Status

coverage: 84.776% (+1.5%) from 83.265% when pulling 1dd01fa on floor-divide-fix-special-cases into 47f4bc9 on master.

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.5dev0=py310h7bf5fec_5 ran successfully.
Passed: 387
Failed: 613
Skipped: 119

@ndgrigorian ndgrigorian force-pushed the floor-divide-fix-special-cases branch from 25f0109 to 01f4571 Compare July 27, 2023 08:19
@github-actions
Copy link

Array API standard conformance tests for dpctl= ran successfully.
Passed: 567
Failed: 433
Skipped: 119

@ndgrigorian ndgrigorian force-pushed the floor-divide-fix-special-cases branch from 01f4571 to c31d020 Compare July 27, 2023 15:14
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_51 ran successfully.
Passed: 567
Failed: 433
Skipped: 119

- Rather than computing division and modulo for each element for sycl::vec, instead the vector is initialized and filled per-element
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_55 ran successfully.
Passed: 594
Failed: 406
Skipped: 119

else {
res[i] = in1[i] / in2[i];
if constexpr (std::is_signed_v<resT>) {
auto mod = in1[i] % in2[i];
Copy link
Contributor

Choose a reason for hiding this comment

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

This performs a second division. How about mod = in1[i] - res[i] * in2[i] instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will try this out as well, I'd like to see how the performance looks.

I have also seen sources suggest that the remainder is, in some cases, a byproduct of division and the compiler can optimize these operations when nearby.

i.e., here under notes

Copy link
Contributor

@oleksandr-pavlyk oleksandr-pavlyk left a comment

Choose a reason for hiding this comment

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

LGTM @ndgrigorian. Thank you

@ndgrigorian ndgrigorian merged commit 02448c4 into master Jul 30, 2023
@github-actions
Copy link

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

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev0=py310h7bf5fec_58 ran successfully.
Passed: 594
Failed: 406
Skipped: 119

@ndgrigorian ndgrigorian deleted the floor-divide-fix-special-cases branch August 10, 2023 17:17
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