Skip to content

Fully enable usm_ndarray in-place arithmetic operators #1352

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 8 commits into from
Aug 18, 2023

Conversation

ndgrigorian
Copy link
Collaborator

This PR completes the implementation of in-place arithmetic operators.

With current behavior, in-place operations simply call the standard implementation and then set the original memory equal to the result. This sometimes leads to unnecessary memory allocation.

By reworking the out keyword, either input operand array can now be used as the output array, and copies are only required for casting and where race conditions must be considered (i.e., when the out array overlaps only some of an input).

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

- A temporary will be allocated as necessary (i.e., when arrays overlap, are not going to be cast, and are not the same logical arrays)
- Uses dedicated in-place kernels where they are implemented
- Now called directly by Python operators
- Removes _inplace method of BinaryElementwiseFunc class
- Removes _find_inplace_dtype function
@github-actions
Copy link

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev3=py310ha25a700_13 ran successfully.
Passed: 913
Failed: 87
Skipped: 119

…p is possible

- Broadcasting can change the values of strides without changing array shape
@coveralls
Copy link
Collaborator

coveralls commented Aug 17, 2023

Coverage Status

coverage: 85.053% (+0.01%) from 85.041% when pulling 3371abd on revise-inplace-operators into bd996b5 on master.

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev3=py310ha25a700_14 ran successfully.
Passed: 913
Failed: 87
Skipped: 119

Use ExecutionPlacementError for CFD violations.
Use ValueError is types of input are as expected, but values are
not as expected.
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev3=py310ha25a700_24 ran successfully.
Passed: 913
Failed: 87
Skipped: 119

Removed tests expecting error raised in case of overlapping inputs.
Added tests guided by coverage report.
@oleksandr-pavlyk oleksandr-pavlyk force-pushed the revise-inplace-operators branch from d9758ee to 1d10f86 Compare August 17, 2023 23:08
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev3=py310ha25a700_24 ran successfully.
Passed: 912
Failed: 88
Skipped: 119

oleksandr-pavlyk and others added 2 commits August 17, 2023 19:43
Since o1_dtype_kind_num > o2_dtype_kind_num, o1 can be not be
weak boolean type, since it has the lowest kind number in the
hierarchy.
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev3=py310ha25a700_25 ran successfully.
Passed: 913
Failed: 87
Skipped: 119

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev3=py310ha25a700_26 ran successfully.
Passed: 913
Failed: 87
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.

I think this is ready to go in, with follow-up PRs to add kernels for more in-place operations (divide, bitwise operations, etc.)

@ndgrigorian ndgrigorian marked this pull request as ready for review August 18, 2023 16:59
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.

Thank you @ndgrigorian . Useful change!

- Removed from test_floor_ceil_trunc, test_hyperbolic, test_trigonometric, and test_logaddexp
- These tests would fail on GPU but never run on CPU, and therefore were not impacting the coverage
- These tests focused on aspects of the BinaryElementwiseFunc class rather than the behavior of the operator
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev3=py310ha25a700_43 ran successfully.
Passed: 913
Failed: 87
Skipped: 119

@ndgrigorian ndgrigorian merged commit 96293fd into master Aug 18, 2023
@ndgrigorian ndgrigorian deleted the revise-inplace-operators branch August 18, 2023 20:52
@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.6dev3=py310ha25a700_44 ran successfully.
Passed: 913
Failed: 87
Skipped: 119

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.6dev4=py310ha25a700_0 ran successfully.
Passed: 913
Failed: 87
Skipped: 119

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