Skip to content

Conversation

@ibsidorenko
Copy link
Contributor

This is enhancement of PR#13327.

Motivation:
Playing with MetaScheduler for Hexagon target it was found that avg_pool2d has rather poor performance due to lack of vectorized code. IndexDataTypeNormalizer pass converts all indices to "int64" format and NarrowDataTypeRewriter should do the opposite (back to "int32"). In case of fail, we have a lot of int64 arithmetic for average pooling that can not be vectorized.

What was done:
Added support of binary ops ("div", "max", "min", "+" etc.) in NarrowDataTypeRewriter. In case of different bitwidth of operands in binary opeation it does downcasting instead of upcasting (as it was before).

Performance impact:
avg_pool2d from quantized InceptionV3 with the shape [1, 8, 35, 35, 32] (NCHW32c layout) tuned with MetaScheduler on Snapdragon 8gen1:

shape Before fix, ms After fix, ms speedup
avg_pool2d, int32 6.67 4.41 +34%

This is enhancement of PR#13327.

Motivation:
Playing with MetaScheduler for Hexagon target it was found that
avg_pool2d has rather poor performance due to lack of vectorized code.
IndexDataTypeNormalizer pass converts all indices to int64 format and
NarrowDataTypeRewriter should do the opposite (back to int32). In case of fail,
we have a lot of int64 arithmetic for average pooling that can not be
vectorized.

What was done:
Added support of binary ops ("div", "max", "min", "+" etc.) in
NarrowDataTypeRewriter. In case of different bitwidth of operands in
binary opeation it does downcasting instead of upcasting (as it was
before).

Performance impact:
avg_pool2d from quantized InceptionV3 with the shape [1, 8, 35, 35, 32]
(NCHW32c layout) tuned with MetaScheduler on Snapdragon 8gen1:

shape             | Before fix, ms | After fix, ms |   speedup   |
------------------|----------------|---------------|-------------|
avg_pool2d, int32 |      6.67      |      4.41     |    +34%     |
-----------------------------------------------------------------|
@tvm-bot
Copy link
Collaborator

tvm-bot commented Mar 14, 2023

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

@ibsidorenko
Copy link
Contributor Author

@tvm-bot rerun

@masahi masahi merged commit 970cd1d into apache:main Mar 15, 2023
@ibsidorenko ibsidorenko deleted the ms-tir-enhancement branch March 15, 2023 07:29
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.

3 participants