From 4d92a6265d1e13784aa695dab5db981f10e29d40 Mon Sep 17 00:00:00 2001 From: liuruilong Date: Mon, 16 Jul 2018 14:24:43 +0800 Subject: [PATCH] remove unused code --- src/common/variant.h | 2 +- src/framework/program/program-optimize/node.cpp | 17 ----------------- src/framework/program/program-optimize/node.h | 3 --- src/operators/batchnorm_op.cpp | 2 +- src/operators/box_coder_op.cpp | 2 +- src/operators/concat_op.cpp | 1 - src/operators/conv_op.cpp | 2 -- src/operators/depthwise_conv_op.cpp | 2 -- src/operators/dropout_op.cpp | 2 +- src/operators/elementwise_add_op.cpp | 2 +- src/operators/feed_op.cpp | 1 - src/operators/fetch_op.cpp | 1 - src/operators/fusion_conv_add.cpp | 1 - src/operators/fusion_conv_add.h | 2 -- src/operators/fusion_conv_add_bn_relu_op.cpp | 2 +- src/operators/fusion_conv_add_bn_relu_op.h | 2 -- src/operators/fusion_fc_op.cpp | 1 - src/operators/im2sequence_op.cpp | 2 -- src/operators/lrn_op.cpp | 2 +- src/operators/mul_op.cpp | 2 +- src/operators/multiclass_nms_op.cpp | 2 +- src/operators/op_param.h | 2 +- src/operators/pool_op.cpp | 2 +- src/operators/prelu_op.cpp | 2 +- src/operators/prior_box_op.cpp | 2 +- src/operators/relu_op.cpp | 2 +- src/operators/reshape_op.cpp | 2 +- src/operators/resize_op.cpp | 2 +- src/operators/scale_op.cpp | 2 +- src/operators/sigmoid_op.cpp | 2 +- src/operators/slice_op.cpp | 2 +- src/operators/softmax_op.cpp | 2 +- src/operators/transpose_op.cpp | 2 +- 33 files changed, 21 insertions(+), 56 deletions(-) diff --git a/src/common/variant.h b/src/common/variant.h index 9d0aa3019f..00b8eb985d 100644 --- a/src/common/variant.h +++ b/src/common/variant.h @@ -84,7 +84,7 @@ struct Variant { if (type_id == typeid(T).hash_code()) { return *const_cast(reinterpret_cast(&data)); } else { - PADDLE_MOBILE_THROW_EXCEPTION(" bad cast in variant "); + PADDLE_MOBILE_THROW_EXCEPTION(" bad cast in variant"); exit(0); } } diff --git a/src/framework/program/program-optimize/node.cpp b/src/framework/program/program-optimize/node.cpp index e635e07eaf..a4e1db506d 100644 --- a/src/framework/program/program-optimize/node.cpp +++ b/src/framework/program/program-optimize/node.cpp @@ -44,23 +44,6 @@ bool Node::operator==(const Node &in) { return true; } -std::vector> Node::OpDescs(int size) { - std::vector> op_descs; - OpDescs(size - 1, &op_descs); - return op_descs; -} - -void Node::OpDescs(int index, - std::vector> *op_desc) { - if (index == 0) { - return; - } - op_desc->push_back(this->op_desc_); - for (auto &output : outputs_) { - output->OpDescs(index, op_desc); - } -} - std::shared_ptr Node::To(int size) { std::shared_ptr node = std::make_shared(); this->To(size - 1, node); diff --git a/src/framework/program/program-optimize/node.h b/src/framework/program/program-optimize/node.h index 88bf1e16ed..7eb179c243 100644 --- a/src/framework/program/program-optimize/node.h +++ b/src/framework/program/program-optimize/node.h @@ -47,13 +47,10 @@ class Node { std::map>> change, std::vector> *removed_nodes); - std::vector> OpDescs(int size); std::shared_ptr OpDescOfNode() { return op_desc_; } std::string Type() { return type_; } private: - void OpDescs(int size, - std::vector> *op_desc); void To(int index, std::shared_ptr); void Folder( std::shared_ptr op_desc, diff --git a/src/operators/batchnorm_op.cpp b/src/operators/batchnorm_op.cpp index 644a27c586..f820908404 100644 --- a/src/operators/batchnorm_op.cpp +++ b/src/operators/batchnorm_op.cpp @@ -26,7 +26,7 @@ void BatchNormOp::InferShape() const { auto x_dims = this->param_.InputX()->dims(); this->param_.OutputY()->Resize(x_dims); } -template class BatchNormOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/box_coder_op.cpp b/src/operators/box_coder_op.cpp index dece07d5ef..9e57c9021d 100644 --- a/src/operators/box_coder_op.cpp +++ b/src/operators/box_coder_op.cpp @@ -47,7 +47,7 @@ void BoxCoderOp::InferShape() const { this->param_.OutputBox()->Resize(framework::make_ddim( {input_targetbox_dims[0], input_priorbox_dims[0], 4})); } -template class BoxCoderOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/concat_op.cpp b/src/operators/concat_op.cpp index 9c524df351..19d771ddd5 100644 --- a/src/operators/concat_op.cpp +++ b/src/operators/concat_op.cpp @@ -56,7 +56,6 @@ void ConcatOp::InferShape() const { this->param_.Out()->Resize(out_dims); } -template class ConcatOp; } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/conv_op.cpp b/src/operators/conv_op.cpp index 1b00ed06ee..c460199521 100644 --- a/src/operators/conv_op.cpp +++ b/src/operators/conv_op.cpp @@ -48,8 +48,6 @@ void ConvOp::InferShape() const { this->param_.Output()->Resize(ddim); } -template class ConvOp; - } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/depthwise_conv_op.cpp b/src/operators/depthwise_conv_op.cpp index bee90781cd..8d6b6a143c 100644 --- a/src/operators/depthwise_conv_op.cpp +++ b/src/operators/depthwise_conv_op.cpp @@ -49,8 +49,6 @@ void DepthwiseConvOp::InferShape() const { this->param_.Output()->Resize(ddim); } -template class DepthwiseConvOp; - } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/dropout_op.cpp b/src/operators/dropout_op.cpp index f7f5ca2475..a632aa0c52 100644 --- a/src/operators/dropout_op.cpp +++ b/src/operators/dropout_op.cpp @@ -22,7 +22,7 @@ void DropoutOp::InferShape() const { auto input_dims = this->param_.InputX()->dims(); this->param_.Out()->Resize(input_dims); } -template class DropoutOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/elementwise_add_op.cpp b/src/operators/elementwise_add_op.cpp index 3695895741..49885f7834 100644 --- a/src/operators/elementwise_add_op.cpp +++ b/src/operators/elementwise_add_op.cpp @@ -24,7 +24,7 @@ void ElementwiseAddOp::InferShape() const { auto x_dim = this->param_.InputX()->dims(); this->param_.Out()->Resize(x_dim); } -template class ElementwiseAddOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/feed_op.cpp b/src/operators/feed_op.cpp index c4357d7993..7fc9101fa8 100644 --- a/src/operators/feed_op.cpp +++ b/src/operators/feed_op.cpp @@ -16,7 +16,6 @@ limitations under the License. */ namespace paddle_mobile { namespace operators { -template class FeedOp; } } // namespace paddle_mobile diff --git a/src/operators/fetch_op.cpp b/src/operators/fetch_op.cpp index cdbe413c95..cecfb28ee7 100644 --- a/src/operators/fetch_op.cpp +++ b/src/operators/fetch_op.cpp @@ -16,7 +16,6 @@ limitations under the License. */ namespace paddle_mobile { namespace operators { -template class FetchOp; } } // namespace paddle_mobile diff --git a/src/operators/fusion_conv_add.cpp b/src/operators/fusion_conv_add.cpp index b1dba23be0..cdd6a6db2b 100644 --- a/src/operators/fusion_conv_add.cpp +++ b/src/operators/fusion_conv_add.cpp @@ -45,7 +45,6 @@ void FusionConvAddOp::InferShape() const { this->param_.Output()->Resize(ddim); } -template class FusionConvAddOp; } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/fusion_conv_add.h b/src/operators/fusion_conv_add.h index ae030ba576..170df9ce33 100644 --- a/src/operators/fusion_conv_add.h +++ b/src/operators/fusion_conv_add.h @@ -36,8 +36,6 @@ class FusionConvAddMatcher : public framework::FusionOpMatcher { void FolderNodes( framework::Node *node, std::vector> *removed_nodes) { - vector> origin_descs = - node->OpDescs(node_.Depth()); node->Folder(node_.Depth(), Type(), {{G_OP_TYPE_ELEMENTWISE_ADD, {{"Y", "Y"}}}}, removed_nodes); } diff --git a/src/operators/fusion_conv_add_bn_relu_op.cpp b/src/operators/fusion_conv_add_bn_relu_op.cpp index 62839c1a5a..16f4650a64 100644 --- a/src/operators/fusion_conv_add_bn_relu_op.cpp +++ b/src/operators/fusion_conv_add_bn_relu_op.cpp @@ -44,7 +44,7 @@ void FusionConvAddBNReluOp::InferShape() const { framework::DDim ddim = framework::make_ddim(output_shape); this->param_.Output()->Resize(ddim); } -template class FusionConvAddBNReluOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/fusion_conv_add_bn_relu_op.h b/src/operators/fusion_conv_add_bn_relu_op.h index 389c76cc83..19e33465c0 100644 --- a/src/operators/fusion_conv_add_bn_relu_op.h +++ b/src/operators/fusion_conv_add_bn_relu_op.h @@ -39,8 +39,6 @@ class FusionConvAddBNReluMatcher : public framework::FusionOpMatcher { void FolderNodes( framework::Node *node, std::vector> *removed_nodes) { - vector> origin_descs = - node->OpDescs(node_.Depth()); node->Folder(node_.Depth(), Type(), {{G_OP_TYPE_ELEMENTWISE_ADD, {{"Y", "Y"}}}, {G_OP_TYPE_BATCHNORM, diff --git a/src/operators/fusion_fc_op.cpp b/src/operators/fusion_fc_op.cpp index 57a8b1b53f..d564d4d88c 100644 --- a/src/operators/fusion_fc_op.cpp +++ b/src/operators/fusion_fc_op.cpp @@ -50,7 +50,6 @@ void FusionFcOp::InferShape() const { this->param_.Out()->Resize(ddim); } -template class FusionFcOp; } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/im2sequence_op.cpp b/src/operators/im2sequence_op.cpp index 273ce462d0..3c929af9cf 100644 --- a/src/operators/im2sequence_op.cpp +++ b/src/operators/im2sequence_op.cpp @@ -47,8 +47,6 @@ void Im2SequenceOp::InferShape() const { this->param_.Output()->Resize(ddim); } -template class Im2SequenceOp; - } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/lrn_op.cpp b/src/operators/lrn_op.cpp index 1a5a8eccc1..dde9123edf 100644 --- a/src/operators/lrn_op.cpp +++ b/src/operators/lrn_op.cpp @@ -24,7 +24,7 @@ void LrnOp::InferShape() const { auto x_dims = this->param_.InputX()->dims(); this->param_.Out()->Resize(x_dims); } -template class LrnOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/mul_op.cpp b/src/operators/mul_op.cpp index 60e0c08738..044da7012e 100644 --- a/src/operators/mul_op.cpp +++ b/src/operators/mul_op.cpp @@ -50,7 +50,7 @@ void MulOp::InferShape() const { framework::DDim ddim = framework::make_ddim(output_dims); this->param_.Out()->Resize(ddim); } -template class MulOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/multiclass_nms_op.cpp b/src/operators/multiclass_nms_op.cpp index eea625469e..4324cab352 100644 --- a/src/operators/multiclass_nms_op.cpp +++ b/src/operators/multiclass_nms_op.cpp @@ -34,7 +34,7 @@ void MultiClassNMSOp::InferShape() const { // pre size, will change in Compute. this->param_.Out()->Resize(framework::make_ddim({input_bboxes_dims[1], 6})); } -template class MultiClassNMSOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/op_param.h b/src/operators/op_param.h index 4ecc1622f9..6de4b77dbe 100644 --- a/src/operators/op_param.h +++ b/src/operators/op_param.h @@ -371,7 +371,7 @@ class BatchNormParam : OpParam { input_variance_ = InputVarianceFrom(inputs, scope); epsilon_ = GetAttr("epsilon", attrs); momentum_ = GetAttr("momentum", attrs); - is_test_ = GetAttr("is_test", attrs); +// is_test_ = GetAttr("is_test", attrs); } const Tensor *InputX() const { return input_x_; } diff --git a/src/operators/pool_op.cpp b/src/operators/pool_op.cpp index 41016d74de..0477c88cf8 100644 --- a/src/operators/pool_op.cpp +++ b/src/operators/pool_op.cpp @@ -54,7 +54,7 @@ void PoolOp::InferShape() const { } this->param_.Output()->Resize(framework::make_ddim(output_shape)); } -template class PoolOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/prelu_op.cpp b/src/operators/prelu_op.cpp index e78f6b0374..245154ca5e 100644 --- a/src/operators/prelu_op.cpp +++ b/src/operators/prelu_op.cpp @@ -23,7 +23,7 @@ void PReluOp::InferShape() const { auto input_dims = this->param_.InputX()->dims(); this->param_.Out()->Resize(input_dims); } -template class PReluOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/prior_box_op.cpp b/src/operators/prior_box_op.cpp index 81ba045a20..a05a0ddcec 100644 --- a/src/operators/prior_box_op.cpp +++ b/src/operators/prior_box_op.cpp @@ -44,7 +44,7 @@ void PriorBoxOp::InferShape() const { this->param_.OutputBoxes()->Resize(framework::make_ddim(dim_vec)); this->param_.OutputVariances()->Resize(framework::make_ddim(dim_vec)); } -template class PriorBoxOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/relu_op.cpp b/src/operators/relu_op.cpp index b80a56f38a..2a771e81e7 100644 --- a/src/operators/relu_op.cpp +++ b/src/operators/relu_op.cpp @@ -23,7 +23,7 @@ void ReluOp::InferShape() const { auto input_dims = this->param_.InputX()->dims(); this->param_.Out()->Resize(input_dims); } -template class ReluOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/reshape_op.cpp b/src/operators/reshape_op.cpp index 193678613c..dcc15009af 100644 --- a/src/operators/reshape_op.cpp +++ b/src/operators/reshape_op.cpp @@ -27,7 +27,7 @@ void ReshapeOp::InferShape() const { auto out_dims = ValidateShape(shape, input_x_dims); this->param_.Out()->Resize(out_dims); } -template class ReshapeOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/resize_op.cpp b/src/operators/resize_op.cpp index f378ff53f5..02c50b6626 100644 --- a/src/operators/resize_op.cpp +++ b/src/operators/resize_op.cpp @@ -24,7 +24,7 @@ void ResizeOp::InferShape() const { auto out_dims = CalOutputShape(this->param_); this->param_.Out()->Resize(out_dims); } -template class ResizeOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/scale_op.cpp b/src/operators/scale_op.cpp index c1931ed4fd..968fcd4098 100644 --- a/src/operators/scale_op.cpp +++ b/src/operators/scale_op.cpp @@ -24,7 +24,7 @@ void ScaleOp::InferShape() const { auto input_dims = this->param_.InputX()->dims(); this->param_.Out()->Resize(input_dims); } -template class ScaleOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/sigmoid_op.cpp b/src/operators/sigmoid_op.cpp index c83738b2c8..8ea4c98942 100644 --- a/src/operators/sigmoid_op.cpp +++ b/src/operators/sigmoid_op.cpp @@ -22,7 +22,7 @@ template void SigmoidOp::InferShape() const { this->param_.Out()->Resize(this->param_.InputX()->dims()); } -template class SigmoidOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/slice_op.cpp b/src/operators/slice_op.cpp index 6d70895fcc..b77a675e10 100644 --- a/src/operators/slice_op.cpp +++ b/src/operators/slice_op.cpp @@ -23,7 +23,7 @@ template void SliceOp::InferShape() const { /// todo: add InputShape() detection. } -template class SliceOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/softmax_op.cpp b/src/operators/softmax_op.cpp index db8fe1d943..c9edfccf4f 100644 --- a/src/operators/softmax_op.cpp +++ b/src/operators/softmax_op.cpp @@ -22,7 +22,7 @@ template void SoftmaxOp::InferShape() const { this->param_.Out()->Resize(this->param_.InputX()->dims()); } -template class SoftmaxOp; + } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/transpose_op.cpp b/src/operators/transpose_op.cpp index 7e578b2901..5f193f9639 100644 --- a/src/operators/transpose_op.cpp +++ b/src/operators/transpose_op.cpp @@ -47,7 +47,7 @@ void TransposeOp::InferShape() const { } this->param_.Out()->Resize(out_dims); } -template class TransposeOp; + } // namespace operators } // namespace paddle_mobile -- GitLab