Skip to content

Implements sign and remainder #1308

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 3 commits into from
Jul 29, 2023
Merged

Implements sign and remainder #1308

merged 3 commits into from
Jul 29, 2023

Conversation

ndgrigorian
Copy link
Collaborator

@ndgrigorian ndgrigorian commented Jul 27, 2023

Implementation of dpctl.tensor.sign and dpctl.tensor.remainder per array API.

Remainder is implemented to emulate the behavior of Python's modulo operator (rather than C's).

Notably, sign (intentionally) breaks with Numpy for complex arrays by being equivalent to z /|z| rather than z/sqrt(z*z) as required by the array API specification.

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

- Sign now uses appropriate templates from elementwise_common namespace
- Sign standardizes returned NaN value
- Added an annotation to `test_sign_negative` clarifying that it is testing for all signed, real data types
@ndgrigorian ndgrigorian force-pushed the impl-sign-remainder branch from 55327b0 to 3786efe Compare July 27, 2023 05:04
@github-actions
Copy link

@coveralls
Copy link
Collaborator

coveralls commented Jul 27, 2023

Coverage Status

coverage: 83.271% (+0.006%) from 83.265% when pulling 2b26908 on impl-sign-remainder into 92aa81d on master.

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

- Added a test for this behavior for signed and unsigned integers
- Implemented l_xor private method to improve remainder readability
@github-actions
Copy link

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

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! Thank you @ndgrigorian

@ndgrigorian ndgrigorian merged commit 22456c4 into master Jul 29, 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_52 ran successfully.
Passed: 595
Failed: 405
Skipped: 119

@ndgrigorian ndgrigorian deleted the impl-sign-remainder branch August 8, 2023 07:56
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