From cbbf08aee950c0402d2fa6f59c3fe1e851113123 Mon Sep 17 00:00:00 2001 From: Abhinav Arora Date: Wed, 18 Apr 2018 17:31:29 -0700 Subject: [PATCH] Fix CPPLint errors in some framework files --- paddle/fluid/framework/concurrency_test.cc | 48 +++++++++---------- paddle/fluid/framework/data_layout.h | 1 + .../fluid/framework/data_layout_transform.cc | 1 + .../fluid/framework/data_layout_transform.h | 1 + paddle/fluid/framework/data_type_transform.h | 1 + paddle/fluid/framework/feed_fetch_method.cc | 2 + paddle/fluid/framework/feed_fetch_method.h | 1 + paddle/fluid/framework/lod_rank_table.h | 1 + paddle/fluid/framework/mixed_vector.h | 1 + paddle/fluid/framework/op_desc.cc | 4 +- paddle/fluid/framework/op_kernel_type.h | 1 + paddle/fluid/framework/op_proto_maker.cc | 1 + paddle/fluid/framework/op_proto_maker.h | 1 + paddle/fluid/framework/shape_inference.cc | 6 ++- paddle/fluid/framework/shape_inference.h | 2 + paddle/fluid/framework/tensor_util.h | 1 + paddle/fluid/framework/var_desc.h | 2 + .../framework/var_type_inference_test.cc | 1 + paddle/fluid/framework/variable.h | 3 +- 19 files changed, 52 insertions(+), 27 deletions(-) diff --git a/paddle/fluid/framework/concurrency_test.cc b/paddle/fluid/framework/concurrency_test.cc index e98e9d94bf7..bbf67f5ba92 100644 --- a/paddle/fluid/framework/concurrency_test.cc +++ b/paddle/fluid/framework/concurrency_test.cc @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include +#include // NOLINT #include "gtest/gtest.h" #include "paddle/fluid/framework/block_desc.h" @@ -40,10 +40,10 @@ namespace paddle { namespace framework { template -LoDTensor *CreateVariable(Scope &scope, p::CPUPlace &place, std::string name, - T value) { +LoDTensor *CreateVariable(Scope *scope, const p::CPUPlace &place, + std::string name, T value) { // Create LoDTensor of dim [1] - auto var = scope.Var(name); + auto var = scope->Var(name); auto tensor = var->GetMutable(); tensor->Resize({1}); T *expect = tensor->mutable_data(place); @@ -77,9 +77,9 @@ void AddCase(ProgramDesc *program, Scope *scope, p::CPUPlace *place, BlockDesc *caseBlock = program->AppendBlock(*casesBlock); func(caseBlock, scope); - CreateVariable(*scope, *place, caseCondName, false); - CreateVariable(*scope, *place, caseCondXVarName, caseId); - CreateVariable(*scope, *place, caseVarName, caseId); + CreateVariable(scope, *place, caseCondName, false); + CreateVariable(scope, *place, caseCondXVarName, caseId); + CreateVariable(scope, *place, caseVarName, caseId); scope->Var("step_scope"); @@ -96,21 +96,21 @@ void AddFibonacciSelect(Scope *scope, p::CPUPlace *place, ProgramDesc *program, std::string quitChanName) { BlockDesc *whileBlock = program->AppendBlock(*parentBlock); - CreateVariable(*scope, *place, "whileExitCond", true); - CreateVariable(*scope, *place, "caseToExecute", -1); - CreateVariable(*scope, *place, "case1var", 0); + CreateVariable(scope, *place, "whileExitCond", true); + CreateVariable(scope, *place, "caseToExecute", -1); + CreateVariable(scope, *place, "case1var", 0); - CreateVariable(*scope, *place, "xtemp", 0); + CreateVariable(scope, *place, "xtemp", 0); // TODO(thuan): Need to create fibXToSend, since channel send moves the actual // data, // which causes the data to be no longer accessible to do the fib calculation // TODO(abhinav): Change channel send to do a copy instead of a move! - CreateVariable(*scope, *place, "fibXToSend", 0); + CreateVariable(scope, *place, "fibXToSend", 0); - CreateVariable(*scope, *place, "fibX", 0); - CreateVariable(*scope, *place, "fibY", 1); - CreateVariable(*scope, *place, "quitVar", 0); + CreateVariable(scope, *place, "fibX", 0); + CreateVariable(scope, *place, "fibY", 1); + CreateVariable(scope, *place, "quitVar", 0); BlockDesc *casesBlock = program->AppendBlock(*whileBlock); std::function f = [](BlockDesc *caseBlock) {}; @@ -138,7 +138,7 @@ void AddFibonacciSelect(Scope *scope, p::CPUPlace *place, ProgramDesc *program, // Exit the while loop after we receive from quit channel. // We assign a false to "whileExitCond" variable, which will // break out of while_op loop - CreateVariable(*scope, *place, "whileFalse", false); + CreateVariable(scope, *place, "whileFalse", false); AddOp("assign", {{"X", {"whileFalse"}}}, {{"Out", {"whileExitCond"}}}, {}, caseBlock); }; @@ -174,9 +174,9 @@ TEST(Concurrency, Go_Op) { // Create Variables, x0 will be put into channel, // result will be pulled from channel - CreateVariable(scope, place, "Status", false); - CreateVariable(scope, place, "x0", 99); - CreateVariable(scope, place, "result", 0); + CreateVariable(&scope, place, "Status", false); + CreateVariable(&scope, place, "x0", 99); + CreateVariable(&scope, place, "result", 0); framework::Executor executor(place); ProgramDesc program; @@ -226,9 +226,9 @@ TEST(Concurrency, Select) { // Initialize scope variables p::CPUDeviceContext ctx(place); - CreateVariable(scope, place, "Status", false); - CreateVariable(scope, place, "result", 0); - CreateVariable(scope, place, "currentXFib", 0); + CreateVariable(&scope, place, "Status", false); + CreateVariable(&scope, place, "result", 0); + CreateVariable(&scope, place, "currentXFib", 0); framework::Executor executor(place); ProgramDesc program; @@ -246,7 +246,7 @@ TEST(Concurrency, Select) { {{"capacity", 0}, {"data_type", f::proto::VarType::LOD_TENSOR}}, block); // Create Go Op routine, which loops 10 times over fibonacci sequence - CreateVariable(scope, place, "xReceiveVar", 0); + CreateVariable(&scope, place, "xReceiveVar", 0); BlockDesc *goOpBlock = program.AppendBlock(program.Block(0)); for (int i = 0; i < 10; ++i) { @@ -264,7 +264,7 @@ TEST(Concurrency, Select) { goOpBlock); } - CreateVariable(scope, place, "quitSignal", 0); + CreateVariable(&scope, place, "quitSignal", 0); AddOp("channel_send", {{"Channel", {quitChanName}}, {"X", {"quitSignal"}}}, {{"Status", {"Status"}}}, {}, goOpBlock); diff --git a/paddle/fluid/framework/data_layout.h b/paddle/fluid/framework/data_layout.h index 39222fc4ed6..9c5e2cf7ccd 100644 --- a/paddle/fluid/framework/data_layout.h +++ b/paddle/fluid/framework/data_layout.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include +#include #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/data_layout_transform.cc b/paddle/fluid/framework/data_layout_transform.cc index 4ca447d50a7..60ec60a427b 100644 --- a/paddle/fluid/framework/data_layout_transform.cc +++ b/paddle/fluid/framework/data_layout_transform.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/data_layout_transform.h" +#include #include "paddle/fluid/operators/math/math_function.h" diff --git a/paddle/fluid/framework/data_layout_transform.h b/paddle/fluid/framework/data_layout_transform.h index ba15be9fc77..06b638663dd 100644 --- a/paddle/fluid/framework/data_layout_transform.h +++ b/paddle/fluid/framework/data_layout_transform.h @@ -14,6 +14,7 @@ #pragma once +#include #include "paddle/fluid/framework/op_kernel_type.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/variable.h" diff --git a/paddle/fluid/framework/data_type_transform.h b/paddle/fluid/framework/data_type_transform.h index e75da2588d0..1c281b03ed6 100644 --- a/paddle/fluid/framework/data_type_transform.h +++ b/paddle/fluid/framework/data_type_transform.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once +#include #include "paddle/fluid/framework/op_kernel_type.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/variable.h" diff --git a/paddle/fluid/framework/feed_fetch_method.cc b/paddle/fluid/framework/feed_fetch_method.cc index a8c3e227db3..8e1f93c5ebd 100644 --- a/paddle/fluid/framework/feed_fetch_method.cc +++ b/paddle/fluid/framework/feed_fetch_method.cc @@ -13,6 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/feed_fetch_method.h" +#include +#include #include "glog/logging.h" #include "paddle/fluid/framework/variable.h" diff --git a/paddle/fluid/framework/feed_fetch_method.h b/paddle/fluid/framework/feed_fetch_method.h index d6130f421e1..7f504bfd232 100644 --- a/paddle/fluid/framework/feed_fetch_method.h +++ b/paddle/fluid/framework/feed_fetch_method.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once +#include #include "paddle/fluid/framework/feed_fetch_type.h" #include "paddle/fluid/framework/scope.h" diff --git a/paddle/fluid/framework/lod_rank_table.h b/paddle/fluid/framework/lod_rank_table.h index ef83e71160e..8c6e8b0c66e 100644 --- a/paddle/fluid/framework/lod_rank_table.h +++ b/paddle/fluid/framework/lod_rank_table.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include +#include #include "paddle/fluid/framework/lod_tensor.h" namespace paddle { diff --git a/paddle/fluid/framework/mixed_vector.h b/paddle/fluid/framework/mixed_vector.h index d99a15547b7..29b3396bc98 100644 --- a/paddle/fluid/framework/mixed_vector.h +++ b/paddle/fluid/framework/mixed_vector.h @@ -14,6 +14,7 @@ #pragma once +#include #include #include diff --git a/paddle/fluid/framework/op_desc.cc b/paddle/fluid/framework/op_desc.cc index eabfdc11a8b..46c834b38b7 100644 --- a/paddle/fluid/framework/op_desc.cc +++ b/paddle/fluid/framework/op_desc.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/op_desc.h" +#include #include -#include +#include // NOLINT +#include #include #include "glog/logging.h" #include "paddle/fluid/framework/block_desc.h" diff --git a/paddle/fluid/framework/op_kernel_type.h b/paddle/fluid/framework/op_kernel_type.h index 3a1036742c2..fab20d75f5a 100644 --- a/paddle/fluid/framework/op_kernel_type.h +++ b/paddle/fluid/framework/op_kernel_type.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once +#include #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/library_type.h" diff --git a/paddle/fluid/framework/op_proto_maker.cc b/paddle/fluid/framework/op_proto_maker.cc index 3116b03d043..c479d7617cf 100644 --- a/paddle/fluid/framework/op_proto_maker.cc +++ b/paddle/fluid/framework/op_proto_maker.cc @@ -12,6 +12,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/op_proto_maker.h" +#include namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/op_proto_maker.h b/paddle/fluid/framework/op_proto_maker.h index cf56b0fa189..0beb57ce160 100644 --- a/paddle/fluid/framework/op_proto_maker.h +++ b/paddle/fluid/framework/op_proto_maker.h @@ -13,6 +13,7 @@ limitations under the License. */ #pragma once +#include #include "paddle/fluid/framework/attribute.h" #include "paddle/fluid/framework/framework.pb.h" diff --git a/paddle/fluid/framework/shape_inference.cc b/paddle/fluid/framework/shape_inference.cc index dc9a79020f1..ddff2c7c261 100644 --- a/paddle/fluid/framework/shape_inference.cc +++ b/paddle/fluid/framework/shape_inference.cc @@ -11,8 +11,12 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ + #include "paddle/fluid/framework/shape_inference.h" -#include "grad_op_desc_maker.h" +#include +#include +#include +#include "paddle/fluid/framework/grad_op_desc_maker.h" #include "paddle/fluid/framework/operator.h" namespace paddle { diff --git a/paddle/fluid/framework/shape_inference.h b/paddle/fluid/framework/shape_inference.h index bc02d700da5..46c8feec001 100644 --- a/paddle/fluid/framework/shape_inference.h +++ b/paddle/fluid/framework/shape_inference.h @@ -14,6 +14,8 @@ limitations under the License. */ #pragma once +#include +#include #include "paddle/fluid/framework/attribute.h" #include "paddle/fluid/framework/ddim.h" #include "paddle/fluid/framework/framework.pb.h" diff --git a/paddle/fluid/framework/tensor_util.h b/paddle/fluid/framework/tensor_util.h index 38b6d1c5c46..78b165ebed1 100644 --- a/paddle/fluid/framework/tensor_util.h +++ b/paddle/fluid/framework/tensor_util.h @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #pragma once +#include #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/framework.pb.h" diff --git a/paddle/fluid/framework/var_desc.h b/paddle/fluid/framework/var_desc.h index f62415fda67..9f7a21ef42b 100644 --- a/paddle/fluid/framework/var_desc.h +++ b/paddle/fluid/framework/var_desc.h @@ -14,6 +14,8 @@ limitations under the License. */ #pragma once +#include +#include #include #include "glog/logging.h" #include "paddle/fluid/framework/framework.pb.h" diff --git a/paddle/fluid/framework/var_type_inference_test.cc b/paddle/fluid/framework/var_type_inference_test.cc index 1dced845ed7..9e33003b442 100644 --- a/paddle/fluid/framework/var_type_inference_test.cc +++ b/paddle/fluid/framework/var_type_inference_test.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/var_type_inference.h" +#include #include "gtest/gtest.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/framework/variable.h b/paddle/fluid/framework/variable.h index 87ddfe2ff9a..067e0c2b838 100644 --- a/paddle/fluid/framework/variable.h +++ b/paddle/fluid/framework/variable.h @@ -14,6 +14,7 @@ #pragma once #include +#include #include #include @@ -67,7 +68,7 @@ class Variable { // parameter of Variable. template struct PlaceholderImpl : public Placeholder { - PlaceholderImpl(T* ptr) : ptr_(ptr), type_(typeid(T)) {} + explicit PlaceholderImpl(T* ptr) : ptr_(ptr), type_(typeid(T)) {} virtual const std::type_info& Type() const { return type_; } virtual void* Ptr() const { return static_cast(ptr_.get()); } -- GitLab