Skip to content

Commit 239dc3d

Browse files
authored
[ARM][kernel] fix pool_compute.cc "x_dims[-1]" bugs (#4918) (#4930)
* [arm][kernels][pooling] pool_compute.cc fix bugs
1 parent 68e64e0 commit 239dc3d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lite/kernels/arm/pool_compute.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void PoolCompute::Run() {
6161
global_pooling = param.global_pooling || global_pooling;
6262
kps_equal = kps_equal && win_ksize;
6363
auto x_dims = param.x->dims();
64+
auto w_in = x_dims[x_dims.size() - 1];
6465

6566
if (global_pooling) {
6667
for (size_t i = 0; i < ksize.size(); ++i) {
@@ -92,8 +93,8 @@ void PoolCompute::Run() {
9293
return;
9394
}
9495
} else {
95-
if (x_dims[-1] > 8 && ksize[0] == 1 && strides[0] == 2 &&
96-
paddings[0] == 0 && kps_equal) {
96+
if (w_in > 8 && ksize[0] == 1 && strides[0] == 2 && paddings[0] == 0 &&
97+
kps_equal) {
9798
auto& ctx = this->ctx_->template As<ARMContext>();
9899
if (pooling_type == "max") {
99100
lite::arm::math::pooling1x1s2p0_max(din,
@@ -109,7 +110,7 @@ void PoolCompute::Run() {
109110
paddings[3]);
110111
return;
111112
}
112-
} else if (x_dims[-1] > 8 && ksize[0] == 2 && strides[0] == 2 &&
113+
} else if (w_in > 8 && ksize[0] == 2 && strides[0] == 2 &&
113114
paddings[0] == 0 && kps_equal) {
114115
if (pooling_type == "max") {
115116
lite::arm::math::pooling2x2s2p0_max(din,
@@ -139,7 +140,7 @@ void PoolCompute::Run() {
139140
paddings[3]);
140141
return;
141142
}
142-
} else if (x_dims[-1] > 8 && ksize[0] == 2 && strides[0] == 2 &&
143+
} else if (w_in > 8 && ksize[0] == 2 && strides[0] == 2 &&
143144
paddings[0] == 1 && kps_equal) {
144145
if (pooling_type == "max") {
145146
lite::arm::math::pooling2x2s2p1_max(din,

0 commit comments

Comments
 (0)