From f8fcc5949343175f4eb4610e6405698c7dce3ef4 Mon Sep 17 00:00:00 2001 From: zhupengyang Date: Thu, 13 Jun 2019 09:06:55 +0000 Subject: [PATCH] fix split unit test --- paddle/fluid/lite/kernels/arm/split_compute_test.cc | 5 ++--- paddle/fluid/lite/operators/split_op.cc | 4 ++-- paddle/fluid/lite/operators/split_op.h | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/lite/kernels/arm/split_compute_test.cc b/paddle/fluid/lite/kernels/arm/split_compute_test.cc index 7d2d95205fc..39632bee8de 100644 --- a/paddle/fluid/lite/kernels/arm/split_compute_test.cc +++ b/paddle/fluid/lite/kernels/arm/split_compute_test.cc @@ -27,7 +27,7 @@ void splite_resize_out(const lite::Tensor* din, const std::vector& dout, int axis, int num, const std::vector& sections) { auto in_dims = din->dims(); - int outs_number; + int outs_number = dout.size(); std::vector outs_dims; outs_dims.reserve(outs_number); @@ -118,11 +118,11 @@ TEST(split_arm, compute) { for (int i = 0; i < x.dims().production(); i++) { x_data[i] = i; } - for (auto out : output) delete out; for (auto out : output_ref) delete out; output.clear(); output_ref.clear(); + int outs_number; if (num > 0) { outs_number = num; @@ -133,7 +133,6 @@ TEST(split_arm, compute) { output.push_back(new lite::Tensor); output_ref.push_back(new lite::Tensor); } - splite_resize_out(&x, output, axis, num, sections); splite_resize_out(&x, output_ref, axis, num, sections); param.x = &x; diff --git a/paddle/fluid/lite/operators/split_op.cc b/paddle/fluid/lite/operators/split_op.cc index 299be81fc0b..9b4b7662ab7 100644 --- a/paddle/fluid/lite/operators/split_op.cc +++ b/paddle/fluid/lite/operators/split_op.cc @@ -31,7 +31,7 @@ bool SplitOp::CheckShape() const { bool SplitOp::InferShape() const { const auto &outs = param_.output; - auto in_dims = param_.x.dims(); + auto in_dims = param_.x->dims(); int axis = param_.axis; int num = param_.num; const auto §ions = param_.sections; @@ -68,7 +68,7 @@ bool SplitOp::AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) { param_.sections = opdesc.GetAttr>("sections"); param_.x = const_cast( &scope->FindVar(opdesc.Input("X").front())->Get()); - auto outs = op_desc.Output("Out").front; + auto outs = opdesc.Output("Out"); for (auto var : outs) { param_.output.push_back(scope->FindVar(var)->GetMutable()); } diff --git a/paddle/fluid/lite/operators/split_op.h b/paddle/fluid/lite/operators/split_op.h index 177c44171e6..20dc4b1028c 100644 --- a/paddle/fluid/lite/operators/split_op.h +++ b/paddle/fluid/lite/operators/split_op.h @@ -23,7 +23,7 @@ namespace paddle { namespace lite { namespace operators { -class SoftmaxOp : public OpLite { +class SplitOp : public OpLite { public: SplitOp() {} explicit SplitOp(const std::string &op_type) : OpLite(op_type) {} -- GitLab