Skip to content

Conversation

christophe-murphy
Copy link
Contributor

These back ends were incorrectly assuming a linear array when finding the max/min value and its index. This causes an issue with a sub-array.

Description

In the case of the cuda and opencl back end this was just for the cpu-fallback methods which are used when the total number of elements in the array is less than or equal to 4096. There was no issue with the oneapi back end because it does not have this fall-back method. The fix for the cuda and opencl back ends was to only use the fall-back method for linear arrays. This is to avoid doing a complex sub-array copy operation from device to host memory.

Changes to Users

af_imax_all / af_imin_all functions now works for sub-arrays

Checklist

  • Rebased on latest master
  • Code compiles
  • Tests pass

…k ends.

These back ends were incorrectly assuming a linear array. In the case of the cuda and opencl back end this was just for the cpu-fallback methods which are used when the total number of elements in the array is less than or equal to 4096.
@christophe-murphy christophe-murphy linked an issue Jun 3, 2025 that may be closed by this pull request
@christophe-murphy christophe-murphy added this to the 3.10 milestone Jun 3, 2025
syurkevi
syurkevi previously approved these changes Jun 3, 2025
Added an eval() to the input array on the CPU back end for the ireduce method to ensure that the array has been evaluated before reducing.
@christophe-murphy christophe-murphy merged commit 0e8a690 into master Jun 25, 2025
1 of 4 checks passed
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.

[BUG] af::max of subarray returns wrong location
3 participants