Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds af::array as a return type to the reduction functions. ( reduceaf::array(arr); )
Description
Previously, the reduce all functions would return a scalar value. The return of an af::array type was missing. Furthermore, the return of a scalar causes a mandatory synchronization at the function call.
Is this a new feature or a bug fix?
New feature
More detail if necessary to describe all commits in pull request.
Partial commits contain separate API changes, kernels for each backend, and tests as described in each commit message. Will be squashed before merging.
Why these changes are necessary.
To improve performance by avoiding unnecessary synchronization at each reduce<>() call.
Potential impact on specific hardware, software or backends.
New functions and their functionality.
Adds af_sum_array, af_sum_nan_array, af_product_array, af_product_nan_array, af_min_array, af_max_array, af_count_array, af_all_true_array, af_any_true_array, and the corresponding C++ versions such as af::maxaf::array(arr);
Can this PR be backported to older versions?
No, breaks API
Changes to Users
Existing code should be compatible. Users can now specify af::array as a template argument for reduction functions.
Checklist