[TOPI][X86] Pool operator parallel support. #4090
Merged
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.
Background #3607 solved a functional bug in Pooling. Earlier, accumulation and division were happening in the same for loop. This was fine for FP32, but caused problem with Integers where division leads to rounded quotient. This bug was solved by putting a separate for loop that just does the division after accumulation has been done.
However, this caused performance issues because the second for loop is no longer paralle. This PR makes the second for loop parallel.
Performance - This leads to very large performance improvement. For my test, for EC2 C5 18x.large machine, the runtime goes from 750 us to 60 us.
There is an additional optimization possible that performs
compute_at
to sink the accumulation inside division. However, that change is much more involved as we have to handle different layouts. So, this PR just does parallel for now.Tests - There are already functional tests that check the correctness. So I don't need any more tests.
@yzhliu @vinx13 @zhiics