Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mli committed Feb 9, 2016
1 parent 435a0b2 commit f7f5c87
Show file tree
Hide file tree
Showing 42 changed files with 124 additions and 363 deletions.
4 changes: 2 additions & 2 deletions include/difacto/learner.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef DIFACTO_LEANRER_H_
#define DIFACTO_LEANRER_H_
#ifndef DIFACTO_LEARNER_H_
#define DIFACTO_LEARNER_H_
#include <string.h>
#include <string>
#include <functional>
Expand Down
2 changes: 1 addition & 1 deletion include/difacto/tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef DIFACTO_TRACKER_H_
#define DIFACTO_TRACKER_H_
#include <string>
#include <utility>
#include <vector>
#include <functional>
#include "./base.h"
Expand Down Expand Up @@ -110,7 +111,6 @@ class Tracker {
* \brief block until the producer called \ref Stop
*/
virtual void Wait() = 0;

};
} // namespace difacto
#endif // DIFACTO_TRACKER_H_
3 changes: 1 addition & 2 deletions src/bcd/bcd_learner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ KWArgs BCDLearner::Init(const KWArgs& kwargs) {

void BCDLearner::IssueJobAndWait(int node_group, const bcd::JobArgs& job,
Tracker::Monitor monitor) {
// TODO
// TODO(mli)
int nworker = model_store_->NumWorkers();
std::vector<std::pair<int, std::string>> jobs(nworker);
for (int i = 0; i < nworker; ++i) {
Expand Down Expand Up @@ -92,7 +92,6 @@ void BCDLearner::RunScheduler() {
for (size_t i = 0; i < feablks.size(); ++i) feablks[i] = i;
epoch_ = 0;
for (; epoch_ < param_.max_num_epochs; ++epoch_) {

bcd::JobArgs iter; iter.type = bcd::JobArgs::kIterateData;
std::random_shuffle(feablks.begin(), feablks.end());
iter.fea_blks = feablks;
Expand Down
8 changes: 5 additions & 3 deletions src/bcd/bcd_learner.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef DEFACTO_LEARNER_BCD_LEARNER_H_
#define DEFACTO_LEARNER_BCD_LEARNER_H_
#ifndef DEFACTO_BCD_BCD_LEARNER_H_
#define DEFACTO_BCD_BCD_LEARNER_H_
#include <vector>
#include <string>
#include "difacto/learner.h"
#include "difacto/store.h"
#include "data/data_store.h"
Expand Down Expand Up @@ -126,4 +128,4 @@ class BCDLearner : public Learner {
};

} // namespace difacto
#endif // DEFACTO_LEARNER_BCD_LEARNER_H_
#endif // DEFACTO_BCD_BCD_LEARNER_H_
6 changes: 3 additions & 3 deletions src/bcd/bcd_param.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef _BCD_PARAM_H_
#define _BCD_PARAM_H_
#ifndef DIFACTO_BCD_BCD_PARAM_H_
#define DIFACTO_BCD_BCD_PARAM_H_
#include "dmlc/parameter.h"
namespace difacto {

Expand Down Expand Up @@ -49,4 +49,4 @@ struct BCDLearnerParam : public dmlc::Parameter<BCDLearnerParam> {
}
};
} // namespace difacto
#endif // _BCD_PARAM_H_
#endif // DIFACTO_BCD_BCD_PARAM_H_
6 changes: 3 additions & 3 deletions src/bcd/bcd_updater.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef _BCD_UPDATER_H_
#define _BCD_UPDATER_H_
#ifndef DIFACTO_BCD_BCD_UPDATER_H_
#define DIFACTO_BCD_BCD_UPDATER_H_
#include <string>
#include <vector>
#include <limits>
Expand Down Expand Up @@ -171,4 +171,4 @@ class BCDUpdater : public Updater {
} // namespace difacto


#endif // _BCD_UPDATER_H_
#endif // DIFACTO_BCD_BCD_UPDATER_H_
6 changes: 3 additions & 3 deletions src/bcd/bcd_utils.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef _BCD_UTILS_H_
#define _BCD_UTILS_H_
#ifndef DIFACTO_BCD_BCD_UTILS_H_
#define DIFACTO_BCD_BCD_UTILS_H_
#include <mutex>
#include <condition_variable>
#include <vector>
Expand Down Expand Up @@ -125,4 +125,4 @@ class Delta {

} // namespace bcd
} // namespace difacto
#endif // _BCD_UTILS_H_
#endif // DIFACTO_BCD_BCD_UTILS_H_
2 changes: 1 addition & 1 deletion src/common/find_position.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ size_t FindPosition(K const* src_begin, K const* src_end,
} else {
*pos = -1;
}
++ dst; ++pos;
++dst; ++pos;
}
}
while (pos != pos_end) {*pos = -1; ++pos; }
Expand Down
14 changes: 7 additions & 7 deletions src/common/kv_match-inl.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef _KV_MATCH_INL_H_
#define _KV_MATCH_INL_H_
#ifndef DIFACTO_COMMON_KV_MATCH_INL_H_
#define DIFACTO_COMMON_KV_MATCH_INL_H_
namespace difacto {

/**
Expand Down Expand Up @@ -35,16 +35,16 @@ void KVMatch(
if (dst_len <= grainsize) {
while (dst_key != dst_key_end && src_key != src_key_end) {
if (*src_key < *dst_key) {
++ src_key; src_val += k;
++src_key; src_val += k;
} else {
if (!(*dst_key < *src_key)) { // equal
for (int i = 0; i < k; ++i) {
AssignFunc(src_val[i], op, &dst_val[i]);
}
++ src_key; src_val += k;
++src_key; src_val += k;
*n += k;
}
++ dst_key; dst_val += k;
++dst_key; dst_val += k;
}
}
} else {
Expand All @@ -55,12 +55,12 @@ void KVMatch(
size_t m = 0;
KVMatch<K, V>(
src_key, src_key_end, src_val,
dst_key + dst_len / 2, dst_key_end, dst_val + ( dst_len / 2 ) * k,
dst_key + dst_len / 2, dst_key_end, dst_val + (dst_len / 2) * k,
k, op, grainsize, &m);
thr.join();
*n += m;
}
}

} // namespace difacto
#endif // _KV_MATCH_INL_H_
#endif // DIFACTO_COMMON_KV_MATCH_INL_H_
3 changes: 2 additions & 1 deletion src/common/kv_match.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define DIFACTO_COMMON_KV_MATCH_H_
#include <vector>
#include <thread>
#include <algorithm>
#include "dmlc/logging.h"
#include "./range.h"
#include "difacto/base.h"
Expand Down Expand Up @@ -34,7 +35,7 @@ inline void AssignFunc(const T& lhs, AssignOp op, T* rhs) {
case MINUS: *rhs -= lhs; break;
case TIMES: *rhs *= lhs; break;
case DIVIDE: *rhs /= lhs; break;
default: LOG(FATAL) << "use AssignOpInt.." ;
default: LOG(FATAL) << "use AssignOpInt..";
}
}
} // namespace difacto
Expand Down
2 changes: 1 addition & 1 deletion src/common/spmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef DIFACTO_COMMON_SPMM_H_
#define DIFACTO_COMMON_SPMM_H_
#include <cstring>
#include <vector>
#include "dmlc/data.h"
#include "dmlc/omp.h"
#include "difacto/sarray.h"
Expand Down Expand Up @@ -177,7 +178,6 @@ class SpMM {
}
}
}

};

} // namespace difacto
Expand Down
3 changes: 2 additions & 1 deletion src/data/data_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef DIFACTO_DATA_DATA_STORE_H_
#define DIFACTO_DATA_DATA_STORE_H_
#include <utility>
#include <string>
#include <memory>
#include <vector>
#include <unordered_map>
Expand Down Expand Up @@ -141,7 +142,7 @@ class DataStore {
if (range.Size() == 0) return range;
CHECK(range.Valid());
size_t siz = size(key);
if (siz == 0) return Range(0,0);
if (siz == 0) return Range(0, 0);
if (range == Range::All()) range = Range(0, siz);
CHECK_LE(range.end, siz);
return range * data_meta_[key].type_size;
Expand Down
1 change: 1 addition & 0 deletions src/data/data_store_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class DataStoreMemory : public DataStoreImpl {
}
void Prefetch(const std::string& key, Range range) override { }
void Remove(const std::string& key) override { store_.erase(key); }

private:
std::unordered_map<std::string,SArray<char>> store_;
};
Expand Down
2 changes: 1 addition & 1 deletion src/data/shared_row_block_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct SharedRowBlockContainer {
* \brief construct by copying from a rowblock
* \param blk the rowblock
*/
SharedRowBlockContainer(const dmlc::RowBlock<IndexType>& blk) {
explicit SharedRowBlockContainer(const dmlc::RowBlock<IndexType>& blk) {
offset.CopyFrom(blk.offset, blk.size+1);
if (blk.label != nullptr) {
label.CopyFrom(blk.label, blk.size);
Expand Down
6 changes: 3 additions & 3 deletions src/data/tile_builder.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef _TILE_BUILDER_H_
#define _TILE_BUILDER_H_
#ifndef DIFACTO_DATA_TILE_BUILDER_H_
#define DIFACTO_DATA_TILE_BUILDER_H_
#include "common/kv_union.h"
#include "common/spmt.h"
#include "data/localizer.h"
Expand Down Expand Up @@ -149,4 +149,4 @@ class TileBuilder {
};

} // namespace difacto
#endif // _TILE_BUILDER_H_
#endif // DIFACTO_DATA_TILE_BUILDER_H_
6 changes: 3 additions & 3 deletions src/data/tile_store.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef _TILE_STORE_H_
#define _TILE_STORE_H_
#ifndef DIFACTO_DATA_TILE_STORE_H_
#define DIFACTO_DATA_TILE_STORE_H_
#include "dmlc/data.h"
#include "difacto/sarray.h"
#include "./shared_row_block_container.h"
Expand Down Expand Up @@ -155,4 +155,4 @@ class TileStore {
};

} // namespace difacto
#endif // _TILE_STORE_H_
#endif // DIFACTO_DATA_TILE_STORE_H_
4 changes: 2 additions & 2 deletions src/lbfgs/lbfgs_learner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void LBFGSLearner::RunScheduler() {
alpha = param_.alpha;
LOG(INFO) << "epoch " << epoch << ": objv " << objv << ", <g,p> " << gp;

std::vector<real_t> status; // = {f(w+αp), <∇f(w+αp), p>}
std::vector<real_t> status; // = {f(w+αp), <∇f(w+αp), p>}
for (int i = 0; i < 10; ++i) {
status.clear();
IssueJobAndWait(NodeID::kWorkerGroup, Job::kLinearSearch, {alpha}, &status);
Expand All @@ -86,7 +86,7 @@ void LBFGSLearner::RunScheduler() {
IssueJobAndWait(NodeID::kWorkerGroup, Job::kEvaluate, {}, &prog);

// check stop critea
// TODO
// TODO(mli)
}
}

Expand Down
1 change: 1 addition & 0 deletions src/lbfgs/lbfgs_learner.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef DIFACTO_LBFGS_LBFGS_LEARNER_H_
#define DIFACTO_LBFGS_LBFGS_LEARNER_H_
#include <string>
#include <vector>
#include "difacto/learner.h"
#include "difacto/base.h"
#include "difacto/sarray.h"
Expand Down
7 changes: 4 additions & 3 deletions src/lbfgs/lbfgs_param.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef _LBFGS_PARAM_H_
#define _LBFGS_PARAM_H_
#ifndef DIFACTO_LBFGS_LBFGS_PARAM_H_
#define DIFACTO_LBFGS_LBFGS_PARAM_H_
#include <string>
#include "dmlc/parameter.h"
namespace difacto {

Expand Down Expand Up @@ -51,4 +52,4 @@ struct LBFGSLearnerParam : public dmlc::Parameter<LBFGSLearnerParam> {
};

} // namespace difacto
#endif // _LBFGS_PARAM_H_
#endif // DIFACTO_LBFGS_LBFGS_PARAM_H_
16 changes: 8 additions & 8 deletions src/lbfgs/lbfgs_twoloop.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef _VECTOR_FREE_H_
#define _VECTOR_FREE_H_
#ifndef DIFACTO_LBFGS_LBFGS_TWOLOOP_H_
#define DIFACTO_LBFGS_LBFGS_TWOLOOP_H_
#include "./lbfgs_utils.h"
namespace difacto {
namespace lbfgs {
Expand Down Expand Up @@ -40,15 +40,15 @@ class Twoloop {
for (int i = 0; i < 2*m+1; ++i) {
std::vector<double> b(2*m+1);
if (i < m - 1) {
const auto& old = B_[i+(m==m_?1:0)];
for (int j = 0; j <= i; ++j) b[j] = old[j+(m==m_?1:0)];
const auto& old = B_[i+(m == m_?1:0)];
for (int j = 0; j <= i; ++j) b[j] = old[j+(m == m_ ? 1 : 0)];
} else if (i == m-1) {
for (int j = 0; j <= i; ++j) b[j] = incr_B[j];
} else if (i < 2*m-1) {
const auto& old = B_[i+(m==m_?1:-1)];
for (int j = 0; j < m; ++j) b[j] = old[j+(m==m_?1:0)];
const auto& old = B_[i+(m == m_?1:-1)];
for (int j = 0; j < m; ++j) b[j] = old[j+(m == m_ ? 1 : 0)];
b[m-1] = incr_B[i];
for (int j = m; j <= i; ++j) b[j] = old[j+(m==m_?1:-1)];
for (int j = m; j <= i; ++j) b[j] = old[j+(m == m_ ? 1 : -1)];
} else if (i == 2*m-1) {
for (int j = 0; j < 2*m; ++j) b[j] = incr_B[2*m+j];
} else {
Expand Down Expand Up @@ -126,4 +126,4 @@ class Twoloop {
};
} // namespace lbfgs
} // namespace difacto
#endif // _VECTOR_FREE_H_
#endif // DIFACTO_LBFGS_LBFGS_TWOLOOP_H_
7 changes: 4 additions & 3 deletions src/lbfgs/lbfgs_updater.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef _LBFGS_UPDATER_H_
#define _LBFGS_UPDATER_H_
#ifndef DIFACTO_LBFGS_LBFGS_UPDATER_H_
#define DIFACTO_LBFGS_LBFGS_UPDATER_H_
#include <vector>
#include "./lbfgs_twoloop.h"
#include "difacto/updater.h"
namespace difacto {
Expand Down Expand Up @@ -133,4 +134,4 @@ class LBFGSUpdater : public Updater {
int nthreads_ = DEFAULT_NTHREADS;
};
} // namespace difacto
#endif // _LBFGS_UPDATER_H_
#endif // DIFACTO_LBFGS_LBFGS_UPDATER_H_
11 changes: 7 additions & 4 deletions src/lbfgs/lbfgs_utils.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/**
* Copyright (c) 2015 by Contributors
*/
#ifndef _LBFGS_UTILS_H_
#define _LBFGS_UTILS_H_
#ifndef DIFACTO_LBFGS_LBFGS_UTILS_H_
#define DIFACTO_LBFGS_LBFGS_UTILS_H_
#include <string>
#include <vector>
#include "dmlc/memory_io.h"
#include "dmlc/omp.h"
#include "difacto/base.h"
Expand Down Expand Up @@ -73,7 +75,8 @@ inline void RemoveTailFeatures(const SArray<feaid_t>& feaids,
SArray<feaid_t>* filtered) {
CHECK_EQ(feaids.size(), feacnts.size());
size_t n = 0;
for (size_t i = 0; i < feaids.size(); ++i) if (feacnts[i] > threshold) ++n;
for (size_t i = 0; i < feaids.size(); ++i)
if (feacnts[i] > threshold) ++n;
filtered->resize(n);
feaid_t* f = filtered->data();
n = 0;
Expand All @@ -84,4 +87,4 @@ inline void RemoveTailFeatures(const SArray<feaid_t>& feaids,

} // namespace lbfgs
} // namespace difacto
#endif // _LBFGS_UTILS_H_
#endif // DIFACTO_LBFGS_LBFGS_UTILS_H_
Loading

0 comments on commit f7f5c87

Please sign in to comment.