-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mlir][tosa][linalg] Apply direct tosa -> linalg Conv2D lowering #68304
Merged
eric-k256
merged 1 commit into
llvm:main
from
FranklandJack:jacfra01/tosa-linalg-conv2d-nhwc+fhwc
Oct 7, 2023
Merged
[mlir][tosa][linalg] Apply direct tosa -> linalg Conv2D lowering #68304
eric-k256
merged 1 commit into
llvm:main
from
FranklandJack:jacfra01/tosa-linalg-conv2d-nhwc+fhwc
Oct 7, 2023
+196
−34
Conversation
This file contains 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
TOSA defines the filter channel ordering for 2D convolution operation `tosa.conv2d` as `[OC, KH, KW, IC]`. The LinAlg dialect supports `[F, H, W, C]` and `[H, W, C, F]` orderings via the `linalg.conv_2d_nhwc_fhwc` and `linalg.conv_2d_nhwc_hwcf` operations respectively. Where `F == OC`, `KH == H`, `KW == W` and `C == IC`. Currently `tosa.conv2d` is lowered to `linalg.conv2d_nhwc_hwcf` meaning we need to insert a transposition operation to permute the filter channels before they can be passed as weights to the linalg op, that is `[F, H, W, C]` -> `[H, W, C, F]`. An analogous transformation needs to be applied to the quantized operation that lowers to `linalg.conv_2d_nhwc_hwcf_q`. This commit updates the TOSA->LinAlg lowering so that `tosa.conv2d` is lowered to `linalg.conv2d_nhwc_fhwc` removing the need for the introduction of a transposition operation and making the mapping 1-1. It also adds a `linalg.conv_2d_nhwc_fhwc_q` quantized operation to the LinAlg dialect so the same direct 1-1 mapping can be applied to the quantized variant. This commit does not add any new lit tests but repurposes the current TosaToLinalgNamed tests by removing the checks for transpositions and updating the targeted LinAlg operations from `linalg.conv2d_nhwc_hwcf` to linalg.conv2d_nhwc_fhwc`. Signed-off-by: Jack Frankland <jack.frankland@arm.com>
FranklandJack
force-pushed
the
jacfra01/tosa-linalg-conv2d-nhwc+fhwc
branch
from
October 5, 2023 13:08
58be62d
to
9e5e7d9
Compare
NatashaKnk
approved these changes
Oct 6, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
stellaraccident
added a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 16, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 18, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 19, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 19, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 19, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 19, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 19, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 19, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 19, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 19, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 19, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 20, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 20, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 20, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 20, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 20, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 20, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Oct 20, 2023
…ing (llvm#68304)" This reverts commit e29a253. Breaking TFLite mobilenet test. Needs triage.
This was referenced Oct 27, 2023
bjacob
added a commit
that referenced
this pull request
Oct 27, 2023
… ops. (#70482) Switching to FHWC happened in #68304 and is fine in itself but caused downstream performance regression iree-org/iree#15296 (comment) , so this PR makes this optional.
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.
TOSA defines the filter channel ordering for 2D convolution operation
tosa.conv2d
as[OC, KH, KW, IC]
. The LinAlg dialect supports[F, H, W, C]
and[H, W, C, F]
orderings via thelinalg.conv_2d_nhwc_fhwc
andlinalg.conv_2d_nhwc_hwcf
operations respectively. WhereF == OC
,KH == H
,KW == W
andC == IC
.Currently
tosa.conv2d
is lowered tolinalg.conv2d_nhwc_hwcf
meaning we need to insert a transposition operation to permute the filter channels before they can be passed as weights to the linalg op, that is[F, H, W, C]
->[H, W, C, F]
. An analogous transformation needs to be applied to the quantized operation that lowers tolinalg.conv_2d_nhwc_hwcf_q
.This commit updates the TOSA->LinAlg lowering so that
tosa.conv2d
is lowered tolinalg.conv2d_nhwc_fhwc
removing the need for the introduction of a transposition operation and making the mapping 1-1. It also adds alinalg.conv_2d_nhwc_fhwc_q
quantized operation to the LinAlg dialect so the same direct 1-1 mapping can be applied to the quantized variant.This commit does not add any new lit tests but repurposes the current TosaToLinalgNamed tests by removing the checks for transpositions and updating the targeted LinAlg operations from
linalg.conv2d_nhwc_hwcf
to linalg.conv2d_nhwc_fhwc`.