From 01bd8dd2ec05020dd531e17b6b3f16b4d823db65 Mon Sep 17 00:00:00 2001 From: Hong Ming Date: Wed, 12 Jun 2019 05:09:54 +0000 Subject: [PATCH] enable conv_winograd, fix conv_gemmlike bug, and update the unit tests of conv op test=develop --- paddle/fluid/lite/kernels/arm/conv_compute.h | 9 +++++-- .../lite/kernels/arm/conv_compute_test.cc | 26 +++++++++++-------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/paddle/fluid/lite/kernels/arm/conv_compute.h b/paddle/fluid/lite/kernels/arm/conv_compute.h index 9b1f970b3a3..21fabf8c3e8 100644 --- a/paddle/fluid/lite/kernels/arm/conv_compute.h +++ b/paddle/fluid/lite/kernels/arm/conv_compute.h @@ -30,10 +30,15 @@ class ConvCompute : public KernelLite { void Run() override; - virtual ~ConvCompute() = default; + ~ConvCompute() { + if (impl_ != nullptr) { + delete impl_; + } + } private: - lite::arm::math::ImplBase* impl_; + lite::arm::math::ImplBase* impl_{ + nullptr}; }; } // namespace arm diff --git a/paddle/fluid/lite/kernels/arm/conv_compute_test.cc b/paddle/fluid/lite/kernels/arm/conv_compute_test.cc index 08362b8c083..f5cffd8eaba 100644 --- a/paddle/fluid/lite/kernels/arm/conv_compute_test.cc +++ b/paddle/fluid/lite/kernels/arm/conv_compute_test.cc @@ -123,11 +123,6 @@ TEST(conv_arm, init) { } TEST(conv_arm, compute) { - lite::Tensor input; - lite::Tensor filter; - lite::Tensor bias; - lite::Tensor output; - lite::Tensor output_ref; DeviceInfo::Init(); for (auto n : {1, 2}) { for (auto ic : {6, 32 /*, 128*/}) { @@ -149,17 +144,26 @@ TEST(conv_arm, compute) { std::vector input_shape = {n, ic, ih, iw}; std::vector filter_shape = {oc, ic / group, ks, ks}; - std::vector output_shape({n, oc}); - const int dkernel = dilation * (ks - 1) + 1; - output_shape.push_back( - (ih + 2 * padding - dkernel) / stride + 1); - output_shape.push_back( - (iw + 2 * padding - dkernel) / stride + 1); + const int dks = dilation * (ks - 1) + 1; + int oh = (ih + 2 * padding - dks) / stride + 1; + int ow = (iw + 2 * padding - dks) / stride + 1; + std::vector output_shape({n, oc, oh, ow}); // resize input, filter and output + Tensor input; + Tensor filter; + Tensor bias; + Tensor output; + Tensor output_ref; input.Resize(input_shape); filter.Resize(filter_shape); output.Resize(output_shape); output_ref.Resize(output_shape); + LOG(INFO) << "input: " << input.dims(); + LOG(INFO) << "filter: " << filter.dims() + << " padding:" << padding + << " stride:" << stride + << " dilation:" << dilation; + LOG(INFO) << "output: " << output.dims(); auto* input_data = input.mutable_data(); auto* filter_data = filter.mutable_data(); auto* output_data = output.mutable_data(); -- GitLab