diff --git a/paddle/operators/pool_cudnn_op.cc b/paddle/operators/pool_cudnn_op.cc index 8307561194e55fdb472ed10d0aeda02b19013f14..f962d9e3e6abde14ce21eb0102f10d139fdb160e 100644 --- a/paddle/operators/pool_cudnn_op.cc +++ b/paddle/operators/pool_cudnn_op.cc @@ -23,12 +23,3 @@ REGISTER_OP_CPU_KERNEL(pool2d_cudnn, ops::PoolKernel); REGISTER_OP_CPU_KERNEL(pool2d_cudnn_grad, ops::PoolGradKernel) - -// REGISTER_OP(pool3d_cudnn, ops::PoolOp, ops::Pool3dOpMaker, pool3d_cudnn_grad, -// ops::PoolOpGrad); -// -// REGISTER_OP_CPU_KERNEL(pool3d_cudnn, -// ops::PoolKernel); -// REGISTER_OP_CPU_KERNEL(pool3d_cudnn_grad, -// ops::PoolGradKernel); diff --git a/paddle/operators/pool_cudnn_op.cu b/paddle/operators/pool_cudnn_op.cu index 8ad22a37559b266534f046a102b72389f268f58e..f9366eb75447bdea0eae7ac4dc3cf1a46dbafaa2 100644 --- a/paddle/operators/pool_cudnn_op.cu +++ b/paddle/operators/pool_cudnn_op.cu @@ -46,11 +46,11 @@ class PoolCudnnOpKernel : public framework::OpKernel { const T *input_data = input->data(); T *output_data = output->mutable_data(ctx.GetPlace()); - std::string pooling_type = ctx.Attr("pooling_type"); + std::string pooling_type = ctx.Attr("poolingType"); std::vector ksize = ctx.Attr>("ksize"); std::vector strides = ctx.Attr>("strides"); std::vector paddings = ctx.Attr>("paddings"); - if (ctx.Attr("global_pooling")) { + if (ctx.Attr("globalPooling")) { for (size_t i = 0; i < ksize.size(); ++i) { ksize[i] = static_cast(input->dims()[i + 2]); } @@ -100,12 +100,12 @@ class PoolCudnnGradOpKernel : public framework::OpKernel { ctx.Input(framework::GradVarName("Out")); Tensor *input_grad = ctx.Output(framework::GradVarName("X")); - std::string pooling_type = ctx.Attr("pooling_type"); + std::string pooling_type = ctx.Attr("poolingType"); std::vector ksize = ctx.Attr>("ksize"); std::vector strides = ctx.Attr>("strides"); std::vector paddings = ctx.Attr>("paddings"); - if (ctx.Attr("global_pooling")) { + if (ctx.Attr("globalPooling")) { for (size_t i = 0; i < ksize.size(); ++i) ksize[i] = static_cast(input->dims()[i + 2]); } @@ -169,6 +169,3 @@ namespace ops = paddle::operators; REGISTER_OP_GPU_KERNEL(pool2d_cudnn, ops::PoolCudnnOpKernel); REGISTER_OP_GPU_KERNEL(pool2d_cudnn_grad, ops::PoolCudnnGradOpKernel); -// -// REGISTER_OP_GPU_KERNEL(pool3d_cudnn, ops::PoolCudnnOpKernel); -// REGISTER_OP_GPU_KERNEL(pool3d_cudnn_grad, ops::PoolCudnnGradOpKernel); diff --git a/paddle/operators/pool_op.cc b/paddle/operators/pool_op.cc index a326839c0f9ad14b8fd2aac596f21c7dd2539cd7..c159f6305c78d082622a6b24bee695d6998a564e 100644 --- a/paddle/operators/pool_op.cc +++ b/paddle/operators/pool_op.cc @@ -29,7 +29,7 @@ void PoolOp::InferShape(framework::InferShapeContext *ctx) const { auto in_x_dims = ctx->GetInputDim("X"); - std::string pooling_type = ctx->Attrs().Get("pooling_type"); + std::string pooling_type = ctx->Attrs().Get("poolingType"); std::vector ksize = ctx->Attrs().Get>("ksize"); std::vector strides = ctx->Attrs().Get>("strides"); std::vector paddings = ctx->Attrs().Get>("paddings"); @@ -37,7 +37,7 @@ void PoolOp::InferShape(framework::InferShapeContext *ctx) const { PADDLE_ENFORCE(in_x_dims.size() == 4 || in_x_dims.size() == 5, "Pooling intput should be 4-D or 5-D tensor."); - if (ctx->Attrs().Get("global_pooling")) { + if (ctx->Attrs().Get("globalPooling")) { ksize.resize(static_cast(in_x_dims.size()) - 2); for (size_t i = 0; i < ksize.size(); ++i) ksize[i] = static_cast(in_x_dims[i + 2]); @@ -80,34 +80,31 @@ Pool2dOpMaker::Pool2dOpMaker(framework::OpProto *proto, "the number of channels, H and W is the height and " "width of feature."); - AddAttr("pooling_type", - "Pooling_type of pooling operator." + AddAttr("poolingType", + "(string), poolingType of pooling operator." "Str constant equal to 'max' or 'avg'.") .InEnum({"max", "avg"}); - AddAttr>( "ksize", - "The pooling window size(height, width) of pooling operator." - "If global_pooling = true, ksize is ignored and need not be " + "(vector ), the pooling window size(height, width) of pooling operator." + "If globalPooling = true, ksize is ignored and need not be " "specified."); // TODO(Chengduo): Add checker. (Currently, - // TypedAttrChecker don't support vector type.) + // TypedAttrChecker don't support vector type.) AddAttr( - "global_pooling", - "Whether to use the global_pooling." - "Bool constant equal to false or true." - "Default false." - "If global_pooling = true, ksize is ignored and need not be specified.") + "globalPooling", + "(bool default: false), whether to use the global pooling." + "If globalPooling = true, ksize is ignored and need not be specified.") .SetDefault(false); - AddAttr>("strides", - "The strides(height, width) of pooling window." - "Default {1,1}.") + AddAttr>( + "strides", + "(vector, default:{1, 1}), strides(height, width) of pooling operator.") .SetDefault({1, 1}); // TODO(Chengduo): Add checker. (Currently, - // TypedAttrChecker don't support vector type.) - AddAttr>("paddings", - "The zero padding(height, width) size on both sides" - "Default {0,0}.") + // TypedAttrChecker don't support vector type.) + AddAttr>( + "paddings", + "(vector defalut:{0,0}), paddings(height, width) of pooling operator.") .SetDefault({0, 0}); // TODO(Chengduo): Add checker. (Currently, - // TypedAttrChecker don't support vector type.) + // TypedAttrChecker don't support vector type.) AddComment(R"DOC( The pooling2d operation calculates the output based on @@ -123,7 +120,6 @@ Example: X shape: (N, C, H_in, W_in) Output: Out shape: (N, C, H_out, W_out) - Mask shape: (N, C, H_out, W_out) where H_out = (H_in - ksize[0] + 2 * paddings[0]) / strides[0] + 1; W_out = (W_in - ksize[1] + 2 * paddings[1]) / strides[1] + 1; @@ -146,33 +142,30 @@ Pool3dOpMaker::Pool3dOpMaker(framework::OpProto *proto, "the number of channels, D, H and W is the depth, height and " "width of feature."); - AddAttr("pooling_type", - "PoolingType of pooling operator." + AddAttr("poolingType", + "(string), poolingType of pooling operator." "Str constant equal to 'max' or 'avg'.") .InEnum({"max", "avg"}); - AddAttr>( "ksize", - "The pooling window size(depth, height, width) of pooling operator." - "If global_pooling = true, ksize is ignored and need not be " + "(vector ), the pooling window size(depth, height, width) of pooling " + "operator." + "If globalPooling = true, ksize is ignored and need not be " "specified."); // TODO(Chengduo): Add checker. (Currently, // TypedAttrChecker don't support vector type.) AddAttr( - "global_pooling", - "Whether to use the global_pooling." - "Bool constant equal to false or true." - "Default false." - "If global_pooling = true, ksize is ignored and need not be specified.") + "globalPooling", + "(bool default: false), whether to use the global pooling." + "If globalPooling = true, ksize is ignored and need not be specified.") .SetDefault(false); AddAttr>("strides", - "Strides(depth, height, width) of pooling operator." - "Default {1,1,1}.") + "(vector, default:{1,1,1}), strides(depth, height, " + "width) of pooling operator.") .SetDefault({1, 1, 1}); // TODO(Chengduo): Add checker. (Currently, // TypedAttrChecker don't support vector type.) - AddAttr>( - "paddings", - "Paddings(depth, height, width) of pooling operator." - "Default {0,0,0}.") + AddAttr>("paddings", + "(vector defalut:{0,0,0}), paddings(depth, height, " + "width) of pooling operator.") .SetDefault({0, 0, 0}); // TODO(Chengduo): Add checker. (Currently, // TypedAttrChecker don't support vector type.) @@ -190,7 +183,6 @@ Example: X shape: (N, C, D_in, H_in, W_in) Output: Out shape: (N, C, D_out, H_out, W_out) - Mask shape: (N, C, D_out, H_out, W_out) where D_out = (D_in - ksize[0] + 2 * paddings[0]) / strides[0] + 1; H_out = (H_in - ksize[1] + 2 * paddings[1]) / strides[1] + 1; diff --git a/paddle/operators/pool_op.h b/paddle/operators/pool_op.h index ada956501918cc92a2d30ebb8d0c42453acd2839..ba8edc9cf60bcf90204ed11fa4fe1d408ad82d40 100644 --- a/paddle/operators/pool_op.h +++ b/paddle/operators/pool_op.h @@ -57,11 +57,11 @@ class PoolKernel : public framework::OpKernel { const Tensor* in_x = context.Input("X"); Tensor* out = context.Output("Out"); - std::string pooling_type = context.Attr("pooling_type"); + std::string pooling_type = context.Attr("poolingType"); std::vector ksize = context.Attr>("ksize"); std::vector strides = context.Attr>("strides"); std::vector paddings = context.Attr>("paddings"); - if (context.Attr("global_pooling")) { + if (context.Attr("globalPooling")) { for (size_t i = 0; i < ksize.size(); ++i) { ksize[i] = static_cast(in_x->dims()[i + 2]); } @@ -117,12 +117,12 @@ class PoolGradKernel : public framework::OpKernel { context.Input(framework::GradVarName("Out")); Tensor* in_x_grad = context.Output(framework::GradVarName("X")); - std::string pooling_type = context.Attr("pooling_type"); + std::string pooling_type = context.Attr("poolingType"); std::vector ksize = context.Attr>("ksize"); std::vector strides = context.Attr>("strides"); std::vector paddings = context.Attr>("paddings"); - if (context.Attr("global_pooling")) { + if (context.Attr("globalPooling")) { for (size_t i = 0; i < ksize.size(); ++i) ksize[i] = static_cast(in_x->dims()[i + 2]); } diff --git a/paddle/operators/pool_with_index_op.cc b/paddle/operators/pool_with_index_op.cc index 29d0322a27b71fe8d335703e228969c084f5139f..d1225eca2b1d8752556a6f688146489eab0dc413 100644 --- a/paddle/operators/pool_with_index_op.cc +++ b/paddle/operators/pool_with_index_op.cc @@ -44,7 +44,7 @@ class MaxPoolWithIndexOp : public framework::OperatorWithKernel { PADDLE_ENFORCE(in_x_dims.size() == 4 || in_x_dims.size() == 5, "Pooling intput should be 4-D or 5-D tensor."); - if (ctx->Attrs().Get("global_pooling")) { + if (ctx->Attrs().Get("globalPooling")) { ksize.resize(static_cast(in_x_dims.size()) - 2); for (size_t i = 0; i < ksize.size(); ++i) ksize[i] = static_cast(in_x_dims[i + 2]); @@ -105,28 +105,25 @@ class MaxPool2dWithIndexOpMaker : public framework::OpProtoAndCheckerMaker { AddAttr>( "ksize", - "The pooling window size(height, width) of pooling operator." - "If global_pooling = true, ksize is ignored and need not be " + "(vector ), the pooling window size(height, width) of pooling operator." + "If globalPooling = true, ksize is ignored and need not be " "specified."); // TODO(Chengduo): Add checker. (Currently, - // TypedAttrChecker don't support vector type.) + // TypedAttrChecker don't support vector type.) AddAttr( - "global_pooling", - "Whether to use the global_pooling." - "Bool constant equal to false or true." - "Default false." - "If global_pooling = true, ksize is ignored and need not be specified.") + "globalPooling", + "(bool default: false), whether to use the global pooling." + "If globalPooling = true, ksize is ignored and need not be specified.") .SetDefault(false); - AddAttr>("strides", - "The strides(height, width) of pooling window." - "Default {1,1}.") + AddAttr>( + "strides", + "(vector, default:{1, 1}), strides(height, width) of pooling operator.") .SetDefault({1, 1}); // TODO(Chengduo): Add checker. (Currently, - // TypedAttrChecker don't support vector type.) + // TypedAttrChecker don't support vector type.) AddAttr>( "paddings", - "The zero padding(height, width) size on both sides" - "Default {0,0}.") + "(vector defalut:{0,0}), paddings(height, width) of pooling operator.") .SetDefault({0, 0}); // TODO(Chengduo): Add checker. (Currently, - // TypedAttrChecker don't support vector type.) + // TypedAttrChecker don't support vector type.) AddComment(R"DOC( The maxPooling2d with index operation calculates the output and the mask @@ -176,29 +173,26 @@ class MaxPool3dWithIndexOpMaker : public framework::OpProtoAndCheckerMaker { AddAttr>( "ksize", - "The pooling window size(depth, height, width) of pooling operator." - "If global_pooling = true, ksize is ignored and need not be " + "(vector ), the pooling window size(depth, height, width) of pooling " + "operator." + "If globalPooling = true, ksize is ignored and need not be " "specified."); // TODO(Chengduo): Add checker. (Currently, - // TypedAttrChecker don't support vector type.) + // TypedAttrChecker don't support vector type.) AddAttr( - "global_pooling", - "Whether to use the global_pooling." - "Bool constant equal to false or true." - "Default false." - "If global_pooling = true, ksize is ignored and need not be specified.") + "globalPooling", + "(bool default: false), whether to use the global pooling." + "If globalPooling = true, ksize is ignored and need not be specified.") .SetDefault(false); - AddAttr>( - "strides", - "Strides(depth, height, width) of pooling operator." - "Default {1,1,1}.") + AddAttr>("strides", + "(vector, default:{1,1,1}), strides(depth, " + "height, width) of pooling operator.") .SetDefault({1, 1, 1}); // TODO(Chengduo): Add checker. (Currently, - // TypedAttrChecker don't support vector type.) - AddAttr>( - "paddings", - "Paddings(depth, height, width) of pooling operator." - "Default {0,0,0}.") + // TypedAttrChecker don't support vector type.) + AddAttr>("paddings", + "(vector defalut:{0,0,0}), paddings(depth, " + "height, width) of pooling operator.") .SetDefault({0, 0, 0}); // TODO(Chengduo): Add checker. (Currently, - // TypedAttrChecker don't support vector type.) + // TypedAttrChecker don't support vector type.) AddComment(R"DOC( The maxpooling3d with index operation calculates the output and the mask diff --git a/paddle/operators/pool_with_index_op.h b/paddle/operators/pool_with_index_op.h index 455c453efcd15bf0150bbd3de83d50729f338b4b..01b961ca8295f723bea7335e43ec5ab100dfc65c 100644 --- a/paddle/operators/pool_with_index_op.h +++ b/paddle/operators/pool_with_index_op.h @@ -35,7 +35,7 @@ class MaxPoolWithIndexKernel : public framework::OpKernel { std::vector ksize = context.Attr>("ksize"); std::vector strides = context.Attr>("strides"); std::vector paddings = context.Attr>("paddings"); - if (context.Attr("global_pooling")) { + if (context.Attr("globalPooling")) { for (size_t i = 0; i < ksize.size(); ++i) { ksize[i] = static_cast(in_x->dims()[i + 2]); } @@ -70,7 +70,7 @@ class MaxPoolWithIndexGradKernel : public framework::OpKernel { std::vector ksize = context.Attr>("ksize"); std::vector strides = context.Attr>("strides"); std::vector paddings = context.Attr>("paddings"); - if (context.Attr("global_pooling")) { + if (context.Attr("globalPooling")) { for (size_t i = 0; i < ksize.size(); ++i) { ksize[i] = static_cast(in_x_grad->dims()[i + 2]); } diff --git a/python/paddle/v2/framework/tests/test_pool2d_cudnn_op.py b/python/paddle/v2/framework/tests/test_pool2d_cudnn_op.py index 7d75191c10fa69bc1aefa8704ac6a03a2e23f76c..8180468014b35bd80dcf474c476558f0587a4ebc 100644 --- a/python/paddle/v2/framework/tests/test_pool2d_cudnn_op.py +++ b/python/paddle/v2/framework/tests/test_pool2d_cudnn_op.py @@ -56,8 +56,8 @@ class TestPool2d_cudnn_Op(OpTest): 'strides': self.strides, 'paddings': self.paddings, 'ksize': self.ksize, - 'pooling_type': self.pool_type, - 'global_pooling': self.global_pool, + 'poolingType': self.pool_type, + 'globalPooling': self.global_pool, } self.outputs = {'Out': output} diff --git a/python/paddle/v2/framework/tests/test_pool2d_op.py b/python/paddle/v2/framework/tests/test_pool2d_op.py index 3fcd8941d4f8a8638db0009b368734c234e702f6..2941fda81b23998072810d8c6f6597a6f3db7e30 100644 --- a/python/paddle/v2/framework/tests/test_pool2d_op.py +++ b/python/paddle/v2/framework/tests/test_pool2d_op.py @@ -56,8 +56,8 @@ class TestPool2d_Op(OpTest): 'strides': self.strides, 'paddings': self.paddings, 'ksize': self.ksize, - 'pooling_type': self.pool_type, - 'global_pooling': self.global_pool, + 'poolingType': self.pool_type, + 'globalPooling': self.global_pool, } self.outputs = {'Out': output} diff --git a/python/paddle/v2/framework/tests/test_pool3d_op.py b/python/paddle/v2/framework/tests/test_pool3d_op.py index f4e938041fa0ae9d0760023afdbf2f3052b244ea..8792b492e3da6541f71185be82b8bfc4f52d821d 100644 --- a/python/paddle/v2/framework/tests/test_pool3d_op.py +++ b/python/paddle/v2/framework/tests/test_pool3d_op.py @@ -64,8 +64,8 @@ class TestPool3d_Op(OpTest): 'strides': self.strides, 'paddings': self.paddings, 'ksize': self.ksize, - 'pooling_type': self.pool_type, - 'global_pooling': self.global_pool, + 'poolingType': self.pool_type, + 'globalPooling': self.global_pool, } self.outputs = {'Out': output}