cloc --read-lang-def=$(PROJECT).cloc src/$(PROJECT)/
lint:
- ./scripts/cpplint.py $(NONGEN_CXX_SRCS)
+ ./scripts/cpp_lint.py $(NONGEN_CXX_SRCS)
test: init $(TEST_BINS)
_regexp_compile_cache = {}
-# Finds occurrences of NOLINT[_NEXTLINE] or NOLINT[_NEXTLINE](...).
-_RE_SUPPRESSION = re.compile(r'\bNOLINT(_NEXTLINE)?\b(\([^)]*\))?')
+# Finds occurrences of NOLINT[_NEXT_LINE] or NOLINT[_NEXT_LINE](...).
+_RE_SUPPRESSION = re.compile(r'\bNOLINT(_NEXT_LINE)?\b(\([^)]*\))?')
# {str, set(int)}: a map from error categories to sets of linenumbers
# on which those errors are expected and should be suppressed.
# FIXME(adonovan): "NOLINT(" is misparsed as NOLINT(*).
matched = _RE_SUPPRESSION.search(raw_line)
if matched:
- if matched.group(1) == '_NEXTLINE':
+ if matched.group(1) == '_NEXT_LINE':
linenum += 1
category = matched.group(2)
if category in (None, '(*)'): # => "suppress all"
const Dtype* bottom_data = bottom[0]->gpu_data();
Dtype* top_data = (*top)[0]->mutable_gpu_data();
const int count = bottom[0]->count();
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
BNLLForward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, bottom_data, top_data);
CUDA_POST_KERNEL_CHECK;
const Dtype* top_diff = top[0]->gpu_diff();
Dtype* bottom_diff = (*bottom)[0]->mutable_gpu_diff();
const int count = (*bottom)[0]->count();
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
BNLLBackward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, top_diff, bottom_data, bottom_diff);
CUDA_POST_KERNEL_CHECK;
int h_off, w_off;
// We only do random crop when we do training.
if (Caffe::phase() == Caffe::TRAIN) {
- // NOLINT_NEXTLINE(runtime/threadsafe_fn)
+ // NOLINT_NEXT_LINE(runtime/threadsafe_fn)
h_off = rand() % (height - cropsize);
- // NOLINT_NEXTLINE(runtime/threadsafe_fn)
+ // NOLINT_NEXT_LINE(runtime/threadsafe_fn)
w_off = rand() % (width - cropsize);
} else {
h_off = (height - cropsize) / 2;
w_off = (width - cropsize) / 2;
}
- // NOLINT_NEXTLINE(runtime/threadsafe_fn)
+ // NOLINT_NEXT_LINE(runtime/threadsafe_fn)
if (mirror && rand() % 2) {
// Copy mirrored version
for (int c = 0; c < channels; ++c) {
iter_->SeekToFirst();
// Check if we would need to randomly skip a few data points
if (this->layer_param_.rand_skip()) {
- // NOLINT_NEXTLINE(runtime/threadsafe_fn)
+ // NOLINT_NEXT_LINE(runtime/threadsafe_fn)
unsigned int skip = rand() % this->layer_param_.rand_skip();
LOG(INFO) << "Skipping first " << skip << " data points.";
while (skip-- > 0) {
CURAND_CHECK(curandGenerate(Caffe::curand_generator(),
(unsigned int*)(rand_vec_->mutable_gpu_data()), count));
// set thresholds
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
DropoutForward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, bottom_data, (unsigned int*)rand_vec_->gpu_data(), uint_thres_,
scale_, top_data);
Dtype* bottom_diff = (*bottom)[0]->mutable_gpu_diff();
const unsigned int* mask = (unsigned int*)rand_vec_->gpu_data();
const int count = (*bottom)[0]->count();
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
DropoutBackward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, top_diff, mask, uint_thres_, scale_, bottom_diff);
CUDA_POST_KERNEL_CHECK;
// We will launch one kernel for each pixel location, and have the kernel
// go through all the channels.
int n_threads = num_ * height_ * width_;
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
LRNFillScale<<<CAFFE_GET_BLOCKS(n_threads), CAFFE_CUDA_NUM_THREADS>>>(
n_threads, bottom_data, num_, channels_, height_, width_, size_,
alpha_ / size_, scale_data);
CUDA_POST_KERNEL_CHECK;
n_threads = bottom[0]->count();
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
LRNComputeOutput<<<CAFFE_GET_BLOCKS(n_threads), CAFFE_CUDA_NUM_THREADS>>>(
n_threads, bottom_data, scale_data, -beta_, top_data);
CUDA_POST_KERNEL_CHECK;
Dtype LRNLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
const bool propagate_down, vector<Blob<Dtype>*>* bottom) {
int n_threads = num_ * height_ * width_;
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
LRNComputeDiff<<<CAFFE_GET_BLOCKS(n_threads), CAFFE_CUDA_NUM_THREADS>>>(
n_threads, (*bottom)[0]->gpu_data(), top[0]->gpu_data(),
scale_.gpu_data(), top[0]->gpu_diff(), num_, channels_, height_, width_,
int count = (*top)[0]->count();
switch (this->layer_param_.pool()) {
case LayerParameter_PoolMethod_MAX:
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
MaxPoolForward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, bottom_data, bottom[0]->num(), CHANNELS_,
HEIGHT_, WIDTH_, POOLED_HEIGHT_, POOLED_WIDTH_, KSIZE_, STRIDE_,
top_data);
break;
case LayerParameter_PoolMethod_AVE:
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
AvePoolForward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, bottom_data, bottom[0]->num(), CHANNELS_,
HEIGHT_, WIDTH_, POOLED_HEIGHT_, POOLED_WIDTH_, KSIZE_, STRIDE_,
// We need to create the random index as well.
CURAND_CHECK(curandGenerateUniform(Caffe::curand_generator(),
rand_idx_.mutable_gpu_data(), count));
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
StoPoolForwardTrain<Dtype><<<CAFFE_GET_BLOCKS(count),
CAFFE_CUDA_NUM_THREADS>>>(
count, bottom_data, bottom[0]->num(), CHANNELS_,
HEIGHT_, WIDTH_, POOLED_HEIGHT_, POOLED_WIDTH_, KSIZE_, STRIDE_,
rand_idx_.mutable_gpu_data(), top_data);
} else {
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
StoPoolForwardTest<Dtype><<<CAFFE_GET_BLOCKS(count),
CAFFE_CUDA_NUM_THREADS>>>(
count, bottom_data, bottom[0]->num(), CHANNELS_,
int count = (*bottom)[0]->count();
switch (this->layer_param_.pool()) {
case LayerParameter_PoolMethod_MAX:
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
MaxPoolBackward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, (*bottom)[0]->gpu_data(), top[0]->gpu_data(), top_diff,
top[0]->num(), CHANNELS_, HEIGHT_, WIDTH_, POOLED_HEIGHT_,
POOLED_WIDTH_, KSIZE_, STRIDE_, bottom_diff);
break;
case LayerParameter_PoolMethod_AVE:
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
AvePoolBackward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, top_diff, top[0]->num(), CHANNELS_,
HEIGHT_, WIDTH_, POOLED_HEIGHT_, POOLED_WIDTH_, KSIZE_, STRIDE_,
bottom_diff);
break;
case LayerParameter_PoolMethod_STOCHASTIC:
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
StoPoolBackward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, rand_idx_.gpu_data(), top_diff,
top[0]->num(), CHANNELS_, HEIGHT_, WIDTH_, POOLED_HEIGHT_,
const Dtype* bottom_data = bottom[0]->gpu_data();
Dtype* top_data = (*top)[0]->mutable_gpu_data();
const int count = bottom[0]->count();
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
ReLUForward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, bottom_data, top_data);
CUDA_POST_KERNEL_CHECK;
const Dtype* top_diff = top[0]->gpu_diff();
Dtype* bottom_diff = (*bottom)[0]->mutable_gpu_diff();
const int count = (*bottom)[0]->count();
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
ReLUBackward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, top_diff, bottom_data, bottom_diff);
CUDA_POST_KERNEL_CHECK;
const Dtype* bottom_data = bottom[0]->gpu_data();
Dtype* top_data = (*top)[0]->mutable_gpu_data();
const int count = bottom[0]->count();
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
SigmoidForward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, bottom_data, top_data);
CUDA_POST_KERNEL_CHECK;
const Dtype* top_diff = top[0]->gpu_diff();
Dtype* bottom_diff = (*bottom)[0]->mutable_gpu_diff();
const int count = (*bottom)[0]->count();
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
SigmoidBackward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, top_diff, bottom_data, bottom_diff);
CUDA_POST_KERNEL_CHECK;
// we need to subtract the max to avoid numerical issues, compute the exp,
// and then normalize.
// Compute max
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
kernel_get_max<Dtype><<<CAFFE_GET_BLOCKS(num), CAFFE_CUDA_NUM_THREADS>>>(
num, dim, bottom_data, scale_data);
// subtraction
caffe_gpu_gemm<Dtype>(CblasNoTrans, CblasNoTrans, num, dim, 1, -1.,
scale_data, sum_multiplier_.gpu_data(), 1., top_data);
// Perform exponentiation
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
kernel_exp<Dtype><<<CAFFE_GET_BLOCKS(num * dim), CAFFE_CUDA_NUM_THREADS>>>(
num * dim, top_data, top_data);
// sum after exp
caffe_gpu_gemv<Dtype>(CblasNoTrans, num, dim, 1., top_data,
sum_multiplier_.gpu_data(), 0., scale_data);
// Do division
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
kernel_softmax_div<Dtype><<<CAFFE_GET_BLOCKS(num * dim),
CAFFE_CUDA_NUM_THREADS>>>(
num, dim, scale_data, top_data);
const Dtype* bottom_data = bottom[0]->gpu_data();
Dtype* top_data = (*top)[0]->mutable_gpu_data();
const int count = bottom[0]->count();
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
TanHForward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, bottom_data, top_data);
CUDA_POST_KERNEL_CHECK;
const Dtype* top_diff = top[0]->gpu_diff();
Dtype* bottom_diff = (*bottom)[0]->mutable_gpu_diff();
const int count = (*bottom)[0]->count();
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
TanHBackward<Dtype><<<CAFFE_GET_BLOCKS(count), CAFFE_CUDA_NUM_THREADS>>>(
count, top_diff, bottom_data, bottom_diff);
CUDA_POST_KERNEL_CHECK;
filler.Fill(this->blob_bottom_data_);
blob_bottom_vec_.push_back(blob_bottom_data_);
for (int i = 0; i < blob_bottom_label_->count(); ++i) {
- // NOLINT_NEXTLINE(runtime/threadsafe_fn)
+ // NOLINT_NEXT_LINE(runtime/threadsafe_fn)
blob_bottom_label_->mutable_cpu_data()[i] = rand() % 5;
}
blob_bottom_vec_.push_back(blob_bottom_label_);
filler.Fill(this->blob_bottom_data_);
blob_bottom_vec_.push_back(blob_bottom_data_);
for (int i = 0; i < blob_bottom_label_->count(); ++i) {
- // NOLINT_NEXTLINE(runtime/threadsafe_fn)
+ // NOLINT_NEXT_LINE(runtime/threadsafe_fn)
blob_bottom_label_->mutable_cpu_data()[i] = rand() % 5;
}
blob_bottom_vec_.push_back(blob_bottom_label_);
int height_col = (height + 2 * pad - ksize) / stride + 1;
int width_col = (width + 2 * pad - ksize) / stride + 1;
int num_kernels = channels * height_col * width_col;
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
im2col_gpu_kernel<Dtype><<<CAFFE_GET_BLOCKS(num_kernels),
CAFFE_CUDA_NUM_THREADS>>>(
num_kernels, data_im, height, width, ksize, pad, stride, height_col,
int num_kernels = channels * height * width;
// To avoid involving atomic operations, we will launch one kernel per
// bottom dimension, and then in the kernel add up the top dimensions.
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
col2im_gpu_kernel<Dtype><<<CAFFE_GET_BLOCKS(num_kernels),
CAFFE_CUDA_NUM_THREADS>>>(
num_kernels, data_col, height, width, channels, ksize, pad, stride,
template <>
void caffe_gpu_mul<float>(const int N, const float* a,
const float* b, float* y) {
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
mul_kernel<float><<<CAFFE_GET_BLOCKS(N), CAFFE_CUDA_NUM_THREADS>>>(
N, a, b, y);
}
template <>
void caffe_gpu_mul<double>(const int N, const double* a,
const double* b, double* y) {
- // NOLINT_NEXTLINE(whitespace/operators)
+ // NOLINT_NEXT_LINE(whitespace/operators)
mul_kernel<double><<<CAFFE_GET_BLOCKS(N), CAFFE_CUDA_NUM_THREADS>>>(
N, a, b, y);
}