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

Implements statistical functions mean, std, var #1465

Merged
merged 6 commits into from
Nov 8, 2023

Conversation

ndgrigorian
Copy link
Collaborator

@ndgrigorian ndgrigorian commented Nov 4, 2023

This pull request

  1. Implements dpctl.tensor.mean, dpctl.tensor.std, and dpctl.tensor.var as top-level functions which leverage tensor submodules.

  2. Resolves dpctl does not return a zero-length array when no reduction is going to be done #1456 by adding logic to tree reduction implementations that populate the output array with the identity when reducing over axes which include a zero-size axis and by adding early exits for py_reduction_over_axis, py_tree_reduction_over_axis, and py_search_over_axis when the destination array is of zero size.
    This permitted removing identity as an argument to the general reduction Python API, as well as removing logic for zero-size array inputs.

  3. Adjusts reduction Python API functions to return a copy of the input array, rather than the input array itself, when no reduction will be performed (i.e., axis=())

  4. Adds additional supported type combinations to sum and prod reductions. Prior to Implements dpctl.tensor.logsumexp and dpctl.tensor.reduce_hypot #1446 , reductions over int inputs with float outputs had dedicated kernels when using atomics to avoid a copy. This pull request adds these type combinations for tree reductions.

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

Copy link

github-actions bot commented Nov 4, 2023

@coveralls
Copy link
Collaborator

coveralls commented Nov 4, 2023

Coverage Status

coverage: 85.942% (+0.1%) from 85.811%
when pulling 9253931 on statistical-functions
into f2af753 on master.

Copy link

github-actions bot commented Nov 4, 2023

Array API standard conformance tests for dpctl=0.15.1dev1=py310ha25a700_5 ran successfully.
Passed: 950
Failed: 50
Skipped: 119

@ndgrigorian ndgrigorian marked this pull request as ready for review November 4, 2023 23:42
Copy link

github-actions bot commented Nov 5, 2023

Array API standard conformance tests for dpctl=0.15.1dev1=py310ha25a700_6 ran successfully.
Passed: 950
Failed: 50
Skipped: 119

Copy link
Collaborator

@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.

Other than the suggestion, this looks great @ndgrigorian ! Thank you for working on implementing these functions.

Copy link

github-actions bot commented Nov 8, 2023

Array API standard conformance tests for dpctl=0.15.1dev1=py310ha25a700_17 ran successfully.
Passed: 950
Failed: 50
Skipped: 119

Copy link
Collaborator

@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

Tree reductions now populate destination with the identity when reducing over
zero-size axes. As a result, logic was removed for handling zero-size axes.

``argmax``, ``argmin``, ``max``, and ``min`` still raise an error for
zero-size axes.

Reductions now return a copy when provided an empty axis tuple.

Adds additional supported dtype combinations to ``prod`` and ``sum``, specifically for input integers and inexact output type
Permits `float` accumulation type with 64 bit integer and unsigned integer inouts
to prevent unnecessary copies on devices that don't support double precision
Mean in-place division now uses the real type for the denominator
Copy link

github-actions bot commented Nov 8, 2023

Array API standard conformance tests for dpctl=0.15.1dev1=py310ha25a700_18 ran successfully.
Passed: 1021
Failed: 51
Skipped: 50

@ndgrigorian ndgrigorian merged commit 9afb742 into master Nov 8, 2023
26 checks passed
@ndgrigorian ndgrigorian deleted the statistical-functions branch November 8, 2023 21:32
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.

dpctl does not return a zero-length array when no reduction is going to be done
3 participants