From 613d3ef084b9863e5473506ff5888eee1b6ec951 Mon Sep 17 00:00:00 2001 From: yuyang18 Date: Thu, 10 May 2018 17:14:05 +0800 Subject: [PATCH] Fix compile error --- paddle/fluid/operators/batch_size_like.h | 6 +++++- paddle/fluid/operators/fill_constant_batch_size_like_op.cc | 4 ++-- .../fluid/operators/gaussian_random_batch_size_like_op.cc | 4 ++-- paddle/fluid/operators/uniform_random_batch_size_like_op.cc | 4 ++-- python/paddle/fluid/layers/layer_function_generator.py | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/paddle/fluid/operators/batch_size_like.h b/paddle/fluid/operators/batch_size_like.h index d01b7e4c8d4..483c9f8c219 100644 --- a/paddle/fluid/operators/batch_size_like.h +++ b/paddle/fluid/operators/batch_size_like.h @@ -53,7 +53,7 @@ class BatchSizeLikeOp : public framework::OperatorWithKernel { class BatchSizeLikeOpMaker : public framework::OpProtoAndCheckerMaker { public: - void Make() override { + void Make() final { AddInput("Input", "(Tensor) Tensor " "whose input_dim_idx'th dimension specifies the batch_size"); @@ -67,7 +67,11 @@ class BatchSizeLikeOpMaker : public framework::OpProtoAndCheckerMaker { AddAttr("output_dim_idx", "(int, default 0) The index of output's batch size dimension") .SetDefault(0); + Apply(); } + + protected: + virtual void Apply() = 0; }; } // namespace operators diff --git a/paddle/fluid/operators/fill_constant_batch_size_like_op.cc b/paddle/fluid/operators/fill_constant_batch_size_like_op.cc index e6bcbecad66..1ae78675a0c 100644 --- a/paddle/fluid/operators/fill_constant_batch_size_like_op.cc +++ b/paddle/fluid/operators/fill_constant_batch_size_like_op.cc @@ -30,8 +30,8 @@ class FillConstantBatchSizeLikeOp : public BatchSizeLikeOp { }; class FillConstantBatchSizeLikeOpMaker : public BatchSizeLikeOpMaker { - public: - void Make() override { + protected: + void Apply() override { AddAttr("dtype", "(int, default 5 (FP32)) " "Output data type") diff --git a/paddle/fluid/operators/gaussian_random_batch_size_like_op.cc b/paddle/fluid/operators/gaussian_random_batch_size_like_op.cc index 45064fc4168..8050f61d454 100644 --- a/paddle/fluid/operators/gaussian_random_batch_size_like_op.cc +++ b/paddle/fluid/operators/gaussian_random_batch_size_like_op.cc @@ -32,8 +32,8 @@ class GaussianRandomBatchSizeLikeOp : public BatchSizeLikeOp { }; class GaussianRandomBatchSizeLikeOpMaker : public BatchSizeLikeOpMaker { - public: - void Make() override { + protected: + void Apply() override { AddAttr("mean", "(float, default 0.0) " "mean of random tensor.") diff --git a/paddle/fluid/operators/uniform_random_batch_size_like_op.cc b/paddle/fluid/operators/uniform_random_batch_size_like_op.cc index aa9f794786b..78fee77df81 100644 --- a/paddle/fluid/operators/uniform_random_batch_size_like_op.cc +++ b/paddle/fluid/operators/uniform_random_batch_size_like_op.cc @@ -32,8 +32,8 @@ class UniformRandomBatchSizeLikeOp : public BatchSizeLikeOp { }; class UniformRandomBatchSizeLikeOpMaker : public BatchSizeLikeOpMaker { - public: - void Make() override { + protected: + void Apply() override { AddComment(R"DOC( Uniform random operator diff --git a/python/paddle/fluid/layers/layer_function_generator.py b/python/paddle/fluid/layers/layer_function_generator.py index 35b01a79914..295d1b7190e 100644 --- a/python/paddle/fluid/layers/layer_function_generator.py +++ b/python/paddle/fluid/layers/layer_function_generator.py @@ -113,7 +113,7 @@ def generate_layer_fn(op_type): if len(not_intermediate_outputs) != 1: raise ValueError("Only one non intermediate output operator can be", - "automatically generated.") + "automatically generated. {0}".format(op_type)) if not_intermediate_outputs[0].duplicable: raise ValueError( -- GitLab