Commit 5ce271e
authored
[MLIR] TosaToLinalgNamed: Lower unsigned tosa.max_pool2d (llvm#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 unsigned1 parent d70f54f commit 5ce271e
File tree
4 files changed
+56
-18
lines changed- mlir
- include/mlir/Conversion/TosaToLinalg
- lib/Conversion/TosaToLinalg
- test/Conversion/TosaToLinalg
4 files changed
+56
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
695 | 695 | | |
696 | 696 | | |
697 | 697 | | |
698 | | - | |
| 698 | + | |
699 | 699 | | |
700 | | - | |
| 700 | + | |
701 | 701 | | |
702 | 702 | | |
703 | 703 | | |
704 | | - | |
| 704 | + | |
| 705 | + | |
705 | 706 | | |
706 | 707 | | |
707 | 708 | | |
708 | | - | |
| 709 | + | |
709 | 710 | | |
710 | 711 | | |
711 | 712 | | |
| |||
744 | 745 | | |
745 | 746 | | |
746 | 747 | | |
747 | | - | |
748 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
749 | 751 | | |
750 | | - | |
751 | | - | |
| 752 | + | |
| 753 | + | |
752 | 754 | | |
753 | | - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
754 | 760 | | |
755 | 761 | | |
756 | | - | |
| 762 | + | |
| 763 | + | |
757 | 764 | | |
758 | 765 | | |
759 | 766 | | |
| |||
762 | 769 | | |
763 | 770 | | |
764 | 771 | | |
765 | | - | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
766 | 776 | | |
767 | 777 | | |
768 | 778 | | |
| |||
798 | 808 | | |
799 | 809 | | |
800 | 810 | | |
801 | | - | |
802 | | - | |
803 | | - | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
804 | 820 | | |
805 | 821 | | |
806 | 822 | | |
| |||
1070 | 1086 | | |
1071 | 1087 | | |
1072 | 1088 | | |
1073 | | - | |
| 1089 | + | |
| 1090 | + | |
1074 | 1091 | | |
1075 | 1092 | | |
1076 | 1093 | | |
| |||
1085 | 1102 | | |
1086 | 1103 | | |
1087 | 1104 | | |
1088 | | - | |
1089 | 1105 | | |
1090 | 1106 | | |
1091 | 1107 | | |
1092 | 1108 | | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
1093 | 1113 | | |
1094 | 1114 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| |||
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
70 | | - | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
203 | 216 | | |
204 | 217 | | |
205 | 218 | | |
| |||
0 commit comments