From 89b4b039dafe4b61d86a901f370767336408391a Mon Sep 17 00:00:00 2001 From: liuqi Date: Mon, 18 Sep 2017 14:21:21 +0800 Subject: [PATCH] Fix pooling test bug and some typo in conv2d test. --- mace/kernels/neon/conv_2d_neon.cc | 38 +++++++++++++++++++------------ mace/ops/pooling_test.cc | 8 +++---- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/mace/kernels/neon/conv_2d_neon.cc b/mace/kernels/neon/conv_2d_neon.cc index f84799e2..0e01def9 100644 --- a/mace/kernels/neon/conv_2d_neon.cc +++ b/mace/kernels/neon/conv_2d_neon.cc @@ -22,6 +22,13 @@ extern void Conv2dNeonK3x3S1(const float *input, float *output, const index_t *output_shape); +extern void Conv2dNeonK3x3S2(const float *input, + const index_t *input_shape, + const float *filter, + const float *bias, + float *output, + const index_t *output_shape); + extern void Conv2dNeonK5x5S1(const float *input, const index_t *input_shape, const float *filter, @@ -30,27 +37,25 @@ extern void Conv2dNeonK5x5S1(const float *input, const index_t *output_shape); template <> -void Conv2dFunctor:: -operator()(const float *input, // NCHW - const index_t *input_shape, - const float *filter, // c_out, c_in, kernel_h, kernel_w - const index_t *filter_shape, - const float *bias, // c_out - float *output, // NCHW - const index_t *output_shape) { +void Conv2dFunctor::operator()(const float *input, + const index_t *input_shape, + const float *filter, + const index_t *filter_shape, + const float *bias, + float *output, + const index_t *output_shape) { typedef void (*Conv2dNeonFunction)( - const float *input, // NCHW + const float *input, const index_t *input_shape, - const float *filter, // c_out, c_in, kernel_h, kernel_w - const float *bias, // c_out - float *output, // NCHW + const float *filter, + const float *bias, + float *output, const index_t *output_shape); // Selection matrix: kernel_size x stride_size static const Conv2dNeonFunction selector[5][2] = { {Conv2dNeonK1x1S1, nullptr}, {nullptr, nullptr}, - {Conv2dNeonK3x3S1, nullptr}, + {Conv2dNeonK3x3S1, Conv2dNeonK3x3S2}, {nullptr, nullptr}, {Conv2dNeonK5x5S1, nullptr}}; // not implement yet @@ -59,7 +64,10 @@ operator()(const float *input, // NCHW if (kernel_h != kernel_w || kernel_h > 5 || strides_[0] != strides_[1] || strides_[0] > 2 || dilations_[0] != 1 || dilations_[1] != 1 || selector[kernel_h - 1][strides_[0] - 1] == nullptr) { - LOG(WARNING) << "NEON conv2d kernel not implementated, using slow vesion"; + LOG(WARNING) << "NEON conv2d kernel with " + << "filter" << kernel_h << "x" << kernel_w << "," + << " stride " << strides_[0] << "x" << strides_[1] + << " is not implemented yet, using slow version"; Conv2dFunctor(strides_, paddings_, dilations_)( input, input_shape, filter, filter_shape, bias, output, output_shape); return; diff --git a/mace/ops/pooling_test.cc b/mace/ops/pooling_test.cc index 7ca43f19..3972743c 100644 --- a/mace/ops/pooling_test.cc +++ b/mace/ops/pooling_test.cc @@ -155,9 +155,9 @@ TEST_F(PoolingOpTest, MAX_k2x2s2x2) { net.RunOp(DeviceType::NEON); // Check - Tensor expected = CreateTensor({1, 1, 2, 3}, {6, 8, 9, 16, 18, 19}); + auto expected = CreateTensor({1, 1, 2, 3}, {6, 8, 9, 16, 18, 19}); - ExpectTensorNear(expected, *net.GetOutput("Output"), 0.001); + ExpectTensorNear(*expected, *net.GetOutput("Output"), 0.001); } TEST_F(PoolingOpTest, MAX_k3x3s2x2) { @@ -183,7 +183,7 @@ TEST_F(PoolingOpTest, MAX_k3x3s2x2) { net.RunOp(DeviceType::NEON); // Check - Tensor expected = CreateTensor({1, 1, 2, 3}, {11, 13, 14, 16, 18, 19}); + auto expected = CreateTensor({1, 1, 2, 3}, {11, 13, 14, 16, 18, 19}); - ExpectTensorNear(expected, *net.GetOutput("Output"), 0.001); + ExpectTensorNear(*expected, *net.GetOutput("Output"), 0.001); } -- GitLab