Skip to content

Commit 2a795df

Browse files
authored
fix sign-compare warning4 (#43625)
1 parent 007f361 commit 2a795df

File tree

10 files changed

+24
-18
lines changed

10 files changed

+24
-18
lines changed

paddle/fluid/distributed/ps/service/brpc_ps_server.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ std::future<int32_t> BrpcPsServer::SendPServer2PServerMsg(
136136
int msg_type, int to_pserver_id, const std::string &msg) {
137137
auto promise = std::make_shared<std::promise<int32_t>>();
138138
std::future<int> fut = promise->get_future();
139-
if (to_pserver_id >= _pserver_channels.size()) {
139+
if (static_cast<size_t>(to_pserver_id) >= _pserver_channels.size()) {
140140
LOG(FATAL) << "to_pserver_id is out of range pservers, which size is "
141141
<< _pserver_channels.size();
142142
promise->set_value(-1);

paddle/fluid/distributed/ps/service/communicator/communicator.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ void AsyncCommunicator::PushSparseFromTensorAsync(
727727
++input_idx;
728728
}
729729
}
730-
CHECK(static_cast<size_t>(output_len) == g_tensor->numel());
730+
CHECK(static_cast<int64_t>(output_len) == g_tensor->numel());
731731
}
732732

733733
std::vector<float *> push_g_vec(input_idx, nullptr);

paddle/fluid/distributed/ps/table/barrier_table.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int32_t BarrierTable::Barrier(const uint32_t trainer_id,
4242
<< " add trainer id: " << trainer_id;
4343
}
4444

45-
if (trainer_ids_.size() < trigger_.load()) {
45+
if (static_cast<int>(trainer_ids_.size()) < trigger_.load()) {
4646
std::vector<uint32_t> diffs(trainer_all_.size());
4747
auto iter = std::set_difference(trainer_all_.begin(), trainer_all_.end(),
4848
trainer_ids_.begin(), trainer_ids_.end(),

paddle/fluid/distributed/ps/table/ctr_double_accessor.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ int32_t CtrDoubleAccessor::Merge(float** update_values,
234234
update_value[i] += other_update_value[i];
235235
}*/
236236
for (size_t i = 0; i < total_dim; ++i) {
237-
if (i != CtrDoublePushValue::SlotIndex()) {
237+
if (static_cast<int>(i) != CtrDoublePushValue::SlotIndex()) {
238238
update_value[i] += other_update_value[i];
239239
}
240240
}

paddle/fluid/distributed/ps/table/memory_dense_table.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ int32_t MemoryDenseTable::Load(const std::string& path,
276276
CHECK(str_len == param_col_ids_.size())
277277
<< "expect " << param_col_ids_.size() << " float, but got "
278278
<< str_len;
279-
for (int col_idx = 0; col_idx < str_len; ++col_idx) {
279+
for (size_t col_idx = 0; col_idx < str_len; ++col_idx) {
280280
if (param_col_ids_[col_idx] < 0) {
281281
continue;
282282
}

paddle/fluid/distributed/ps/table/memory_sparse_table.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ int32_t MemorySparseTable::InitializeValue() {
5353
_avg_local_shard_num =
5454
sparse_local_shard_num(_sparse_table_shard_num, _shard_num);
5555
_real_local_shard_num = _avg_local_shard_num;
56-
if (_real_local_shard_num * (_shard_idx + 1) > _sparse_table_shard_num) {
56+
if (static_cast<int>(_real_local_shard_num * (_shard_idx + 1)) >
57+
_sparse_table_shard_num) {
5758
_real_local_shard_num =
5859
_sparse_table_shard_num - _real_local_shard_num * _shard_idx;
5960
_real_local_shard_num =

paddle/fluid/distributed/ps/table/sparse_accessor.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ int32_t SparseAccessor::Merge(float** update_values,
202202
float* update_value = update_values[value_item];
203203
const float* other_update_value = other_update_values[value_item];
204204
for (size_t i = 0; i < total_dim; ++i) {
205-
if (i != SparsePushValue::SlotIndex()) {
205+
if (static_cast<int>(i) != SparsePushValue::SlotIndex()) {
206206
update_value[i] += other_update_value[i];
207207
}
208208
}

paddle/fluid/distributed/ps/table/ssd_sparse_table.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,9 @@ int32_t SSDSparseTable::Load(size_t start_idx, size_t end_idx,
637637
size_t mf_value_size =
638638
_value_accesor->GetAccessorInfo().mf_size / sizeof(float);
639639

640-
end_idx =
641-
end_idx < _sparse_table_shard_num ? end_idx : _sparse_table_shard_num;
640+
end_idx = static_cast<int>(end_idx) < _sparse_table_shard_num
641+
? end_idx
642+
: _sparse_table_shard_num;
642643
int thread_num = (end_idx - start_idx) < 20 ? (end_idx - start_idx) : 20;
643644
omp_set_num_threads(thread_num);
644645
#pragma omp parallel for schedule(dynamic)

paddle/fluid/distributed/ps/wrapper/fleet.cc

+12-8
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,12 @@ void FleetWrapper::PushSparseFromTensorAsync(
555555
// in
556556
// ctr_accessor.h
557557
push_values.back()[0] = 2; // TODO(zhaocaibei123): slot
558-
push_values.back()[1] =
559-
(i >= show_size ? 1 : static_cast<float>(show_tensor[i]));
560-
push_values.back()[2] =
561-
(i >= clk_size ? 0 : static_cast<float>(clk_tensor[i]));
558+
push_values.back()[1] = (static_cast<int>(i) >= show_size
559+
? 1
560+
: static_cast<float>(show_tensor[i]));
561+
push_values.back()[2] = (static_cast<int>(i) >= clk_size
562+
? 0
563+
: static_cast<float>(clk_tensor[i]));
562564
float* data = push_values.back().data() + 3;
563565
memcpy(data, g + output_len, sizeof(float) * fea_dim);
564566
}
@@ -582,10 +584,12 @@ void FleetWrapper::PushSparseFromTensorAsync(
582584
// slot show clk grad... consistent with CtrCommonPushValue defined in
583585
// ctr_accessor.h
584586
push_values.back()[0] = 2; // TODO(zhaocaibei123): slot
585-
push_values.back()[1] =
586-
(i >= show_size ? 1 : static_cast<float>(show_tensor[i]));
587-
push_values.back()[2] =
588-
(i >= clk_size ? 0 : static_cast<float>(clk_tensor[i]));
587+
push_values.back()[1] = (static_cast<int>(i) >= show_size
588+
? 1
589+
: static_cast<float>(show_tensor[i]));
590+
push_values.back()[2] = (static_cast<int>(i) >= clk_size
591+
? 0
592+
: static_cast<float>(clk_tensor[i]));
589593
float* data = push_values.back().data() + 3;
590594
memcpy(data, g + output_len, sizeof(float) * fea_dim);
591595
}

paddle/fluid/distributed/test/ctr_accessor_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ TEST(downpour_feature_value_accessor_test, test_update) {
239239
push_v.show = grad[i][1];
240240
push_v.click = grad[i][2];
241241
push_v.embed_g = grad[i][3];
242-
for (int j = 0; j < parameter.embedx_dim(); ++j) {
242+
for (unsigned int j = 0; j < parameter.embedx_dim(); ++j) {
243243
push_v.embedx_g.push_back(grad[i][4 + j]);
244244
}
245245

0 commit comments

Comments
 (0)