portable: add fast path for contiguous innermost-dim reduction in amax.out and amin.out#21142
portable: add fast path for contiguous innermost-dim reduction in amax.out and amin.out#21142vacu9708 wants to merge 1 commit into
Conversation
….out and amin.out Adds a fast path to amax.out and amin.out: when the input tensor is contiguous and reduced over just its innermost dimension, compute the result with a direct loop instead of the generic path's per-row index recomputation. Output is unchanged, and existing tests already cover both the fast path and the fallback. Continues the reduction fast-path work in pytorch#18789, pytorch#18790, pytorch#18791. Signed-off-by: Youngsik Yang <vacu9708@gmail.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21142
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below:
|
This PR needs a
|
Motivation
sum.IntList_out,mean.out, andvar_mean.correction_outspecial-case the contiguous, single innermost-dim reduction shape with a direct pointer loop instead of the genericReduceOverDimListPlan, which recomputes a stride-based starting index per output element viaget_init_index(#18789, #18790, #18791).amax.outandamin.outdo not have this fast path.Tests
No new tests were added. The existing tests already cover both fast and generic paths.
sum's (#18789),mean's (#18790), andvar_mean's (#18791) fast-path PRs had no test changes either.dimAllRealInputOutputPasses{2,3,4}{2}(innermost)ET_FORALL_REALHBBF16_TYPES(incl.Bool,Half,BFloat16)AllRealInputOutputPasses{2,3,4}{-2}(not innermost)AllRealInputOutputPasses{2,3,4}{0,1}(multi-dim)AllRealInputOutputPasses{2,2,4}InfinityAndNANTest{2,3,4}{-1}(innermost)ET_FORALL_FLOATHBF16_TYPESSame coverage in both
op_amax_test.cppandop_amin_test.cpp.