Skip to content

Commit

Permalink
fix cpp lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dcslin committed Feb 27, 2020
1 parent 5f12612 commit 27cd860
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ filter=-readability/todo
filter=-build/c++11
filter=-build/c++14
filter=-build/c++tr1
filter=-build/namespaces
filter=-build/header_guard
filter=-runtime/explicit
2 changes: 1 addition & 1 deletion include/singa/io/communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class Communicator {
float *backupBuff;
int *fusedIndex;
};
}
} // namespace singa

#endif // USE_DIST
#endif
17 changes: 17 additions & 0 deletions include/singa/utils/cuda_utils.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* 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.
*/
// from caffe include/caffe/util/device_alternative.hpp
#ifndef SINGA_UTILS_CUDA_UTILS_H_
#define SINGA_UTILS_CUDA_UTILS_H_
Expand Down
4 changes: 2 additions & 2 deletions include/singa/utils/dnnl_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using namespace dnnl;

inline dnnl::memory::format_tag get_dnnl_format_tag(const Tensor &x){
memory::format_tag format_tag_;
switch(x.nDim()){
switch (x.nDim()){
case 1:{
format_tag_ = memory::format_tag::a;
break;
Expand All @@ -51,5 +51,5 @@ inline dnnl::memory::format_tag get_dnnl_format_tag(const Tensor &x){
return format_tag_;
}

}
} // namespace singa
#endif // SINGA_UTILS_MKLDNN_UTILS_H_
2 changes: 1 addition & 1 deletion include/singa/utils/integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ static int readInteger(char* buf, Type& value, Types&... values) {
value = ntoh(*(Type*)buf);
return sizeof(Type) + readInteger(buf + sizeof(Type), values...);
}
}
} // namespace singa
#endif
2 changes: 1 addition & 1 deletion include/singa/utils/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ class Timer {
private:
std::chrono::high_resolution_clock::time_point last_;
};
}
} // namespace singa
#endif
2 changes: 1 addition & 1 deletion src/core/memory/memory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void CudaMemPool::Free(void *ptr) {
cudaError_t status = cudaFree(ptr);
CHECK_EQ(status, cudaError_t::cudaSuccess);
}
}
} // namespace singa
#endif

#endif
2 changes: 1 addition & 1 deletion src/core/tensor/math_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void removezeroidx(const size_t n, int *in, cudaStream_t s, int *address);

void sortbykey(const size_t n, float *key, int *value, cudaStream_t s);

} // cuda
} // namespace cuda

} // namespace singa

Expand Down
2 changes: 1 addition & 1 deletion src/core/tensor/sparse_tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
#include "singa/core/tensor.h"
namespace singa {}

#endif
#endif
2 changes: 1 addition & 1 deletion src/io/communicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,6 @@ void Communicator::topKSparsAllReduce(size_t num, float *accumulation) {
fusedRecvBuff, CUSPARSE_INDEX_BASE_ONE));
}
}
}
} // namespace singa

#endif // USE_DIST
4 changes: 2 additions & 2 deletions src/model/operation/batchnorm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
************************************************************/
#include <cctype>

#include "./batchnorm.h"
#include "src/model/operation/batchnorm.h"

namespace singa {

Expand Down Expand Up @@ -405,4 +405,4 @@ const std::vector<Tensor> GpuBatchNormBackward(
}

#endif // USE_CUDNN
}
} // namespace singa
2 changes: 1 addition & 1 deletion src/model/operation/convolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <cctype>

#include "../layer/convolution.h"
#include "./convolution.h"
#include "src/model/operation/convolution.h"

namespace singa {

Expand Down
2 changes: 1 addition & 1 deletion src/model/operation/pooling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* under the License.
*
************************************************************/
#include "./pooling.h"
#include "src/model/operation/pooling.h"
#include <cmath>

namespace singa {
Expand Down
4 changes: 3 additions & 1 deletion tool/linting/cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ find src/api/ \
include/singa/io/communicator.h \
src/io/communicator.cc \
test/singa/ -iname *.h -o -iname *.cc | xargs cpplint --quiet --verbose=5

CPPLINTRESULT=$?
if [[ $CPPLINTRESULT ]]; then

if [ $CPPLINTRESULT -ne 0 ]; then
echo $CPPLINTRESULT
echo "cpplint not passed"
exit 1
Expand Down

0 comments on commit 27cd860

Please sign in to comment.