[all-commits] [llvm/llvm-project] e29a25: [mlir][tosa][linalg] Apply direct tosa -> linalg C...
Jack Frankland via All-commits
all-commits at lists.llvm.org
Fri Oct 6 17:10:52 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e29a253c9ebaded53a823def985364392c4ba4ec
https://github.com/llvm/llvm-project/commit/e29a253c9ebaded53a823def985364392c4ba4ec
Author: Jack Frankland <30410009+FranklandJack at users.noreply.github.com>
Date: 2023-10-06 (Fri, 06 Oct 2023)
Changed paths:
M mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
M mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
M mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py
M mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-named.mlir
Log Message:
-----------
[mlir][tosa][linalg] Apply direct tosa -> linalg Conv2D lowering (#68304)
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 at arm.com>
More information about the All-commits
mailing list