Skip to content

Commit 07cdb42

Browse files
committed
add integer MaxPool1D for Generic platform and add tests for both int and float MaxPool1D
1 parent f792722 commit 07cdb42

26 files changed

Lines changed: 87 additions & 54 deletions

File tree

.github/workflows/ci-deeploy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ jobs:
129129
python testTilerExtension.py -p Siracusa -t ./Tests/Models/CNN_Linear2
130130
python testTilerExtension.py -p Siracusa -t ./Tests/Models/CNN_Linear1
131131
python testTilerExtension.py -p Siracusa -t ./Tests/Kernels/Integer/MatMul/Regular
132-
python testTilerExtension.py -p Siracusa -t ./Tests/Kernels/Integer/MaxPool
132+
python testTilerExtension.py -p Siracusa -t ./Tests/Kernels/Integer/MaxPool/Regular_2D
133133
python testTilerExtension.py -p Siracusa -t ./Tests/Models/CNN_Linear2 --l1 2000 --shouldFail
134134
python testTilerExtension.py -p Siracusa -t ./Tests/Models/CNN_Linear1 --l1 2000 --shouldFail
135135
python testTilerExtension.py -p Siracusa -t ./Tests/Kernels/Integer/MatMul/Regular --l1 2000 --shouldFail
136-
python testTilerExtension.py -p Siracusa -t ./Tests/Kernels/Integer/MaxPool --l1 2000 --shouldFail
136+
python testTilerExtension.py -p Siracusa -t ./Tests/Kernels/Integer/MaxPool/Regular_2D --l1 2000 --shouldFail
137137
138138
deeploy-memory-allocation-extension:
139139
needs: select-env
@@ -157,7 +157,7 @@ jobs:
157157
python testTilerExtension.py -p Siracusa -t ./Tests/Models/miniMobileNet
158158
python testTilerExtension.py -p Siracusa -t ./Tests/Models/miniMobileNetv2
159159
python testTilerExtension.py -p Siracusa -t ./Tests/Kernels/Integer/MatMul/Regular
160-
python testTilerExtension.py -p Siracusa -t ./Tests/Kernels/Integer/MaxPool
160+
python testTilerExtension.py -p Siracusa -t ./Tests/Kernels/Integer/MaxPool/Regular_2D
161161
162162
deeploy-typing:
163163
needs: select-env

.github/workflows/ci-platform-cortexm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
Kernels/Integer/Pad/Regular_2D
4343
Kernels/Integer/MatMul/Regular
4444
Kernels/Integer/MatMul/Add
45-
Kernels/Integer/MaxPool
45+
Kernels/Integer/MaxPool/Regular_2D
4646
Kernels/Integer/Conv/Regular_2D_RQ
4747
Kernels/Integer/ReduceSum
4848
Kernels/Integer/ReduceMean

.github/workflows/ci-platform-generic.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
Kernels/FP32/Div
5353
Kernels/FP32/GEMM/Regular
5454
Kernels/FP32/MatMul
55-
Kernels/FP32/MaxPool
55+
Kernels/FP32/MaxPool/Regular_2D
5656
Kernels/FP32/Mul
5757
5858
Kernels/FP32/LayerNorm
@@ -101,7 +101,7 @@ jobs:
101101
Kernels/Integer/MatMul/Add
102102
Kernels/Integer/MatMul/Regular
103103
104-
Kernels/Integer/MaxPool
104+
Kernels/Integer/MaxPool/Regular_2D
105105
106106
Kernels/Integer/Pad/Regular_1D
107107
Kernels/Integer/Pad/Regular_2D

.github/workflows/ci-platform-mempool.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
Kernels/Integer/MatMul/Add
5151
Kernels/Integer/MatMul/Regular
5252
53-
Kernels/Integer/MaxPool
53+
Kernels/Integer/MaxPool/Regular_2D
5454
5555
Kernels/Integer/Pad/Regular_1D
5656
Kernels/Integer/Pad/Regular_2D

.github/workflows/ci-platform-siracusa-tiled.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
5252
{"name":"Kernels/FP32/GEMM/Regular","L1":[8000]},
5353
{"name":"Kernels/FP32/MatMul","L1":[2000]},
54-
{"name":"Kernels/FP32/MaxPool","L1":[2000]},
54+
{"name":"Kernels/FP32/MaxPool/Regular_2D","L1":[2000]},
5555
{"name":"Kernels/FP32/Mul","L1":[2000]},
5656
{"name":"Kernels/FP32/LayerNorm","L1":[2000]},
5757
@@ -116,7 +116,7 @@ jobs:
116116
117117
{"name":"Kernels/FP32/GEMM/Regular","L1":[8000]},
118118
{"name":"Kernels/FP32/MatMul","L1":[5000]},
119-
{"name":"Kernels/FP32/MaxPool","L1":[5000]},
119+
{"name":"Kernels/FP32/MaxPool/Regular_2D","L1":[5000]},
120120
{"name":"Kernels/FP32/Mul","L1":[2000]},
121121
{"name":"Kernels/FP32/LayerNorm","L1":[2000]},
122122

.github/workflows/ci-platform-siracusa.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
5555
Kernels/FP32/GEMM/Regular
5656
Kernels/FP32/MatMul
57-
Kernels/FP32/MaxPool
57+
Kernels/FP32/MaxPool/Regular_2D
5858
Kernels/FP32/Mul
5959
Kernels/FP32/LayerNorm
6060

Deeploy/Targets/Generic/Bindings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@
165165
]
166166

167167
BasicMaxPool1DBindings = [
168+
NodeBinding(MaxPoolChecker([PointerClass(int8_t)], [PointerClass(int8_t)]), MaxPoolTemplate.reference1DTemplate,
169+
BasicTransformer)
170+
] + [
168171
NodeBinding(MaxPoolChecker([PointerClass(type)], [PointerClass(type)]), FloatMaxPoolTemplate.reference1DTemplate,
169172
BasicTransformer) for type in FloatDataTypes
170173
]

Deeploy/Targets/Generic/Templates/MaxPoolTemplate.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from Deeploy.DeeployTypes import NetworkContext, NodeTemplate, OperatorRepresentation
88

99

10-
class _MaxPool2DTemplate(NodeTemplate):
10+
class _MaxPoolTemplate(NodeTemplate):
1111

1212
def __init__(self, templateStr):
1313
super().__init__(templateStr)
@@ -28,7 +28,7 @@ def alignToContext(self, ctxt: NetworkContext,
2828
return ctxt, operatorRepresentation, []
2929

3030

31-
referenceTemplate = _MaxPool2DTemplate("""
31+
referenceTemplate = _MaxPoolTemplate("""
3232
<%
3333
batchOffsetIn = ch_im_in * dim_im_in_x * dim_im_in_y
3434
batchOffsetOut = ch_im_out * dim_im_out_x * dim_im_out_y
@@ -50,3 +50,24 @@ def alignToContext(self, ctxt: NetworkContext,
5050
}
5151
END_SINGLE_CORE
5252
""")
53+
54+
reference1DTemplate = _MaxPoolTemplate("""
55+
<%
56+
batchOffsetIn = ch_im_in * dim_im_in_y
57+
batchOffsetOut = ch_im_out * dim_im_out_y
58+
%>
59+
// 1D MaxPool (Name: ${nodeName}, Op: ${nodeOp})
60+
BEGIN_SINGLE_CORE
61+
${data_in_type.typeName} ref_${data_out}_${data_in} = ${data_in};
62+
${data_out_type.typeName} ref_${data_out}_${data_out} = ${data_out};
63+
for (uint32_t n=0; n<${batch}; ++n) {
64+
MaxPool1d_s${data_in_type.referencedType.typeWidth}_s${data_out_type.referencedType.typeWidth}(
65+
ref_${data_out}_${data_in}, ${ch_im_in}, ${dim_im_in_y},
66+
${dim_kernel_y}, ${stride_y},
67+
ref_${data_out}_${data_out}, ${input_offset}, ${output_offset}
68+
);
69+
ref_${data_out}_${data_in} += ${batchOffsetIn};
70+
ref_${data_out}_${data_out} += ${batchOffsetOut};
71+
}
72+
END_SINGLE_CORE
73+
""")
4.26 KB
Binary file not shown.
223 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)