[all-commits] [llvm/llvm-project] 5ce271: [MLIR] TosaToLinalgNamed: Lower unsigned tosa.max_...

Matthias Gehre via All-commits all-commits at lists.llvm.org
Mon Jan 20 04:42:39 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5ce271ef74dd3325993c827f496e460ced41af11
      https://github.com/llvm/llvm-project/commit/5ce271ef74dd3325993c827f496e460ced41af11
  Author: Matthias Gehre <matthias.gehre at amd.com>
  Date:   2025-01-20 (Mon, 20 Jan 2025)

  Changed paths:
    M mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h
    M mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
    M mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamedPass.cpp
    M mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-named.mlir

  Log Message:
  -----------
  [MLIR] TosaToLinalgNamed: Lower unsigned tosa.max_pool2d (#123290)

This PR allows to lower **unsigned** `tosa.max_pool2d` to linalg.
```
// CHECK-LABEL: @max_pool_ui8
func.func @max_pool_ui8(%arg0: tensor<1x6x34x62xui8>) -> tensor<1x4x32x62xui8> {
  // CHECK: builtin.unrealized_conversion_cast {{.*}} : tensor<1x6x34x62xui8> to tensor<1x6x34x62xi8>
  // CHECK: arith.constant 0
  // CHECK: linalg.pooling_nhwc_max_unsigned {{.*}} : (tensor<1x4x32x62xi8>) -> tensor<1x4x32x62xi8>
  // CHECK: builtin.unrealized_conversion_cast {{.*}} : tensor<1x4x32x62xi8> to tensor<1x4x32x62xui8>
  %0 = tosa.max_pool2d %arg0 {pad = array<i64: 0, 0, 0, 0>, kernel = array<i64: 3, 3>, stride = array<i64: 1, 1>} : (tensor<1x6x34x62xui8>) -> tensor<1x4x32x62xui8>
  return %0 : tensor<1x4x32x62xui8>
}
```
It does this by
- converting the MaxPool2dConverter from OpRewriterPattern to
OpConversion Pattern
- adjusting the padding value to the the minimum unsigned value when the
max_pool is unsigned
- lowering to `linalg.pooling_nhwc_max_unsigned` (which uses
`arith.maxui`) when the max_pool is unsigned



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list