Skip to content

Commit

Permalink
Fix clang-tidy.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Aug 5, 2018
1 parent 58e9e15 commit 707eea2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/common/hist_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ void HistCutMatrix::Init(DMatrix* p_fmat, uint32_t max_num_bins) {
for (size_t i = 0; i < batch.Size(); ++i) { // NOLINT(*)
size_t ridx = batch.base_rowid + i;
SparsePage::Inst inst = batch[i];
for (bst_uint j = 0; j < inst.size(); ++j) {
if (inst[j].index >= begin && inst[j].index < end) {
sketchs[inst[j].index].Push(inst[j].fvalue, info.GetWeight(ridx));
for (auto& ins : inst) {
if (ins.index >= begin && ins.index < end) {
sketchs[ins.index].Push(ins.fvalue, info.GetWeight(ridx));
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/data/simple_dmatrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ void SimpleDMatrix::MakeOneBatch(SparsePage* pcol, bool sorted) {
for (long i = 0; i < batch_size; ++i) { // NOLINT(*)
int tid = omp_get_thread_num();
auto inst = batch[i];
for (bst_uint j = 0; j < inst.size(); ++j) {
builder.AddBudget(inst[j].index, tid);
for (auto& ins : inst) {
builder.AddBudget(ins.index, tid);
}
}
}
Expand All @@ -72,11 +72,11 @@ void SimpleDMatrix::MakeOneBatch(SparsePage* pcol, bool sorted) {
for (long i = 0; i < static_cast<long>(batch.Size()); ++i) { // NOLINT(*)
int tid = omp_get_thread_num();
auto inst = batch[i];
for (bst_uint j = 0; j < inst.size(); ++j) {
builder.Push(
inst[j].index,
Entry(static_cast<bst_uint>(batch.base_rowid + i), inst[j].fvalue),
tid);
for (auto& ins : inst) {
builder.Push(ins.index,
Entry(static_cast<bst_uint>(batch.base_rowid + i),
ins.fvalue),
tid);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/gbm/gblinear.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ class GBLinear : public GradientBooster {
for (int gid = 0; gid < ngroup; ++gid) {
bst_float *p_contribs = &contribs[(row_idx * ngroup + gid) * ncolumns];
// calculate linear terms' contributions
for (bst_uint c = 0; c < inst.size(); ++c) {
if (inst[c].index >= model_.param.num_feature) continue;
p_contribs[inst[c].index] = inst[c].fvalue * model_[inst[c].index][gid];
for (auto& ins : inst) {
if (ins.index >= model_.param.num_feature) continue;
p_contribs[ins.index] = ins.fvalue * model_[ins.index][gid];
}
// add base margin to BIAS
p_contribs[ncolumns - 1] = model_.bias()[gid] +
Expand Down
12 changes: 6 additions & 6 deletions src/linear/updater_shotgun.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ class ShotgunUpdater : public LinearUpdater {
auto col = batch[ii];
for (int gid = 0; gid < ngroup; ++gid) {
double sum_grad = 0.0, sum_hess = 0.0;
for (bst_uint j = 0; j < col.size(); ++j) {
GradientPair &p = gpair[col[j].index * ngroup + gid];
for (auto& c : col) {
GradientPair &p = gpair[c.index * ngroup + gid];
if (p.GetHess() < 0.0f) continue;
const bst_float v = col[j].fvalue;
const bst_float v = c.fvalue;
sum_grad += p.GetGrad() * v;
sum_hess += p.GetHess() * v * v;
}
Expand All @@ -107,10 +107,10 @@ class ShotgunUpdater : public LinearUpdater {
if (dw == 0.f) continue;
w += dw;
// update grad values
for (bst_uint j = 0; j < col.size(); ++j) {
GradientPair &p = gpair[col[j].index * ngroup + gid];
for (auto& c : col) {
GradientPair &p = gpair[c.index * ngroup + gid];
if (p.GetHess() < 0.0f) continue;
p += GradientPair(p.GetHess() * col[j].fvalue * dw, 0);
p += GradientPair(p.GetHess() * c.fvalue * dw, 0);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/tree/updater_histmaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,8 @@ class QuantileHistMaker: public HistMaker<TStats> {
if (this->node2workindex_[nid] < 0) {
this->position_[ridx] = ~nid;
} else {
for (bst_uint j = 0; j < inst.size(); ++j) {
builder.AddBudget(inst[j].index, omp_get_thread_num());
for (auto& ins : inst) {
builder.AddBudget(ins.index, omp_get_thread_num());
}
}
}
Expand All @@ -806,9 +806,9 @@ class QuantileHistMaker: public HistMaker<TStats> {
const bst_uint ridx = static_cast<bst_uint>(batch.base_rowid + i);
const int nid = this->position_[ridx];
if (nid >= 0) {
for (bst_uint j = 0; j < inst.size(); ++j) {
builder.Push(inst[j].index,
Entry(nid, inst[j].fvalue),
for (auto& ins : inst) {
builder.Push(ins.index,
Entry(nid, ins.fvalue),
omp_get_thread_num());
}
}
Expand Down

0 comments on commit 707eea2

Please sign in to comment.