arm: add ROIAlign NEON implementation#6781
Draft
devin-lai wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds an ARM NEON pack4 implementation for ROIAlign.
The main change is in the bilinear accumulation helper. The previous helper accumulated all four interpolation corners into one
_sum, which made the inner loop latency-bound as the sample count grew. The NEON path now keeps the four corner accumulators independent and reduces them at the end.For ROIAlign version 0, this also hoists repeated per-cell metadata out of the channel loop. The bounds, coordinate sets, bin grid, and pixel area are computed once per ROI instead of once per channel.
Performance
Benchmark setup:
num_threads=16e359b6f66efebb57 x 1000iterationsThe common
sampling_ratio=2cases improve by about1.2xto1.3xfor version 0, mainly from avoiding repeated metadata work inside the channel loop. Version 1 is mostly neutral there because it does not have the same redundant per-channel setup and the dependency chain is short.When the sample count is higher, either from
sampling_ratio=0on larger feature maps or explicitsampling_ratio=4, the independent accumulators matter more and both versions improve by about1.65xto1.73x.No tested configuration regressed.
Correctness
tests/test_roialign.cpppasses, including added pack4 coverage forsampling_ratio=0.The scalar path is unchanged. The pack4 result matches the original implementation within normal floating-point reassociation differences; the maximum absolute difference observed across 60,544 sampled outputs was
2.4e-7.