[MetaSchedule][Hexagon] Improve vectorization for standalone elementwise op#14408
Merged
masahi merged 1 commit intoapache:mainfrom Mar 28, 2023
Merged
[MetaSchedule][Hexagon] Improve vectorization for standalone elementwise op#14408masahi merged 1 commit intoapache:mainfrom
masahi merged 1 commit intoapache:mainfrom
Conversation
…ise ops
Motivation:
It was found that for standalone elementwise operations (add, sub, etc.)
MetaScheduler generates code with poor performance due to lack of vector
code on some input tensor shapes. Current implementation is not able to
vectorize if innermost loops extent is not multiple of the vector
length.
What was done:
Core changes: it checks current loops nest, if all loops are "simple",
i.e. loops without annotations, bindings, reduce axis, then it does the
following:
1) Fuse all loops into single one.
2) Split this new loop into 2 parts: inner and outer. Herewith split
factor for the inner loop is equal to 'max_vectorize_extent'
MetaScheduler parameter.
3) Parallelize outer loop and vectorize inner loop.
Performance measurement:
Measurement was done on Qualcomm Snapdragon 888. As it was expected, 1
and 2 got significant performance boost, 3 and 4 - without changes.
N | op | Dtype | Shape | Before fix, ms | After fix, ms | speedup |
--|---------|-------|------------------|----------------|---------------|---------|
1 | add | uint8 | 1, 8, 56, 56, 32 | 1.264 | 0.167 | 7.5x |
2 | qnn.add | uint8 | 1, 8, 56, 56, 32 | 2.213 | 0.336 | 6.6x |
3 | add | int32 | 1, 8, 56, 56, 32 | 0.161 | 0.150 | 1.07x |
4 | seq* | uint8 | 1, 64, 56, 56 | 2.634 | 2.679 | 0.98x |
----------------------------------------------------------------------------------|
seq* - test of the ops sequence: qnn.conv2d + bias_add + qnn.requantize,
weights shape = [256, 64, 1, 1]
Collaborator
|
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
Contributor
Author
|
@tvm-bot rerun |
masahi
approved these changes
Mar 28, 2023
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.
Motivation:
It was found that for standalone elementwise operations (add, sub, etc.) MetaScheduler generates code with poor performance due to lack of vector code on some input tensor shapes. Current implementation is not able to vectorize if innermost loops extent is not multiple of the vector length.
What was done:
Core changes: it checks current loops nest, if all loops are "simple", i.e. loops without annotations, bindings, reduce axis, then it does the following:
Performance measurement:
Measurement was done on Qualcomm Snapdragon 888. As it was expected, 1 and 2 got significant performance boost, 3 and 4 - without changes.
seq* - test of the ops sequence: qnn.conv2d + bias_add + qnn.requantize,
weights shape = [256, 64, 1, 1]