diff --git a/paddle/fluid/lite/kernels/arm/conv_compute.h b/paddle/fluid/lite/kernels/arm/conv_compute.h index 9b1f970b3a3a22c9fe7164d071c285ceaaef18b8..21fabf8c3e8f7983a891265135c39b96aaf42e8d 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 08362b8c08397041f8284aecdd25547c058f7a1a..f5cffd8eaba8a6f71106944edc6335baf1e72ff5 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();