From e47f4186ae0c504016466e060b7df997755b591e Mon Sep 17 00:00:00 2001 From: Tao Luo Date: Wed, 17 Oct 2018 20:47:39 +0800 Subject: [PATCH] fix some compiler warning --- paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc | 2 +- paddle/fluid/framework/program_desc.cc | 4 ++-- paddle/fluid/framework/reader_test.cc | 2 +- paddle/fluid/framework/selected_rows_test.cc | 2 +- paddle/fluid/operators/reader/reader_blocking_queue_test.cc | 2 +- paddle/fluid/operators/sequence_unpad_op.cc | 2 +- paddle/fluid/operators/sequence_unpad_op.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc b/paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc index 1c75cb5a820..6090f1fe76a 100644 --- a/paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc +++ b/paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc @@ -262,7 +262,7 @@ std::unique_ptr AttentionLSTMFusePass::ApplyImpl( std::unordered_set specified_vars({"data_lod_attention", "cell_init", "hidden_init", "data", "week", "minute"}); - int count = 0; + size_t count = 0; for (auto* node : graph->Nodes()) { if (node->IsVar() && specified_vars.count(node->Name())) { ++count; diff --git a/paddle/fluid/framework/program_desc.cc b/paddle/fluid/framework/program_desc.cc index 589905828f7..4b9667113bc 100644 --- a/paddle/fluid/framework/program_desc.cc +++ b/paddle/fluid/framework/program_desc.cc @@ -126,7 +126,7 @@ const std::vector ProgramDesc::GetFeedTargetNames() { std::vector feed_target_names; for (auto *op : global_block.AllOps()) { if (op->Type() == kFeedOpType) { - int col = boost::get(op->GetAttr("col")); + size_t col = boost::get(op->GetAttr("col")); if (col >= feed_target_names.size()) { feed_target_names.resize(col + 1); } @@ -143,7 +143,7 @@ const std::vector ProgramDesc::GetFetchTargetNames() { std::vector fetch_target_names; for (auto *op : global_block.AllOps()) { if (op->Type() == kFetchOpType) { - int col = boost::get(op->GetAttr("col")); + size_t col = boost::get(op->GetAttr("col")); if (col >= fetch_target_names.size()) { fetch_target_names.resize(col + 1); } diff --git a/paddle/fluid/framework/reader_test.cc b/paddle/fluid/framework/reader_test.cc index f0d07cb7c13..50aca4b5a4b 100644 --- a/paddle/fluid/framework/reader_test.cc +++ b/paddle/fluid/framework/reader_test.cc @@ -39,7 +39,7 @@ TEST(READER, decorate_chain) { { auto endpoints = root->GetEndPoints(); ASSERT_EQ(endpoints.size(), 2U); - ASSERT_NE(endpoints.count(end_point1.get()), 0); + ASSERT_NE(endpoints.count(end_point1.get()), 0UL); ASSERT_NE(endpoints.count(end_point2.get()), 0); } diff --git a/paddle/fluid/framework/selected_rows_test.cc b/paddle/fluid/framework/selected_rows_test.cc index 928e1ad8b91..9c427a4ae4c 100644 --- a/paddle/fluid/framework/selected_rows_test.cc +++ b/paddle/fluid/framework/selected_rows_test.cc @@ -91,7 +91,7 @@ TEST(SelectedRows, SparseTable) { ASSERT_TRUE(table.HasKey(10)); ASSERT_TRUE(table.HasKey(8)); ASSERT_TRUE(table.HasKey(6)); - ASSERT_EQ(table.rows().size(), 3); + ASSERT_EQ(table.rows().size(), 3UL); framework::Tensor ids; ids.Resize(framework::make_ddim({4})); diff --git a/paddle/fluid/operators/reader/reader_blocking_queue_test.cc b/paddle/fluid/operators/reader/reader_blocking_queue_test.cc index bd7ac64b2fc..8cd50580605 100644 --- a/paddle/fluid/operators/reader/reader_blocking_queue_test.cc +++ b/paddle/fluid/operators/reader/reader_blocking_queue_test.cc @@ -229,7 +229,7 @@ TEST(BlockingQueue, speed_test_mode) { q1.Receive(&b); EXPECT_EQ(b, i); } - EXPECT_EQ(q1.Size(), 0); + EXPECT_EQ(q1.Size(), 0UL); BlockingQueue q2(queue_size, true); for (size_t i = 0; i < queue_size; ++i) { diff --git a/paddle/fluid/operators/sequence_unpad_op.cc b/paddle/fluid/operators/sequence_unpad_op.cc index f3a0762b9a4..e633e378a22 100644 --- a/paddle/fluid/operators/sequence_unpad_op.cc +++ b/paddle/fluid/operators/sequence_unpad_op.cc @@ -50,7 +50,7 @@ class SequenceUnpadOp : public framework::OperatorWithKernel { if (x_dims.size() == 2) { out_dims_vec.push_back(1); } else { - for (size_t i = 2; i < x_dims.size(); ++i) { + for (int i = 2; i < x_dims.size(); ++i) { out_dims_vec.push_back(x_dims[i]); } } diff --git a/paddle/fluid/operators/sequence_unpad_op.h b/paddle/fluid/operators/sequence_unpad_op.h index ebe3118b985..07df3dca831 100644 --- a/paddle/fluid/operators/sequence_unpad_op.h +++ b/paddle/fluid/operators/sequence_unpad_op.h @@ -61,7 +61,7 @@ class SequenceUnpadOpKernel : public framework::OpKernel { if (x_t->dims().size() == 2) { out_dims_vec.push_back(1); } else { - for (size_t i = 2; i < x_t->dims().size(); ++i) { + for (int i = 2; i < x_t->dims().size(); ++i) { out_dims_vec.push_back(x_t->dims()[i]); } } -- GitLab