Skip to content

Commit bddcae8

Browse files
Rob Hessjeffdonahue
authored andcommitted
Try to obey google style guide.
1 parent 9420cea commit bddcae8

File tree

2 files changed

+59
-55
lines changed

2 files changed

+59
-55
lines changed

include/caffe/device.hpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,16 @@ class Device {
113113
Dtype* y) { NOT_IMPLEMENTED; }
114114

115115
virtual void im2col(const Dtype* data_im, const int channels,
116-
const int height, const int width, const int ksize, const int pad,
117-
const int stride, Dtype* data_col) { NOT_IMPLEMENTED; }
116+
const int height, const int width, const int ksize,
117+
const int pad, const int stride, Dtype* data_col) {
118+
NOT_IMPLEMENTED;
119+
}
118120

119121
virtual void col2im(const Dtype* data_col, const int channels,
120-
const int height, const int width, const int ksize, const int pad,
121-
const int stride, Dtype* data_im) { NOT_IMPLEMENTED; }
122+
const int height, const int width, const int ksize,
123+
const int pad, const int stride, Dtype* data_im) {
124+
NOT_IMPLEMENTED;
125+
}
122126
};
123127

124128
template<typename Dtype>
@@ -178,7 +182,7 @@ class CPUDevice : public Device<Dtype> {
178182
virtual Dtype dot(const int N, const Dtype* x, const Dtype* y);
179183

180184
virtual uint32_t hamming_distance(const int N, const Dtype* x,
181-
const Dtype* y);
185+
const Dtype* y);
182186

183187
// Returns the sum of the absolute values of the elements of vector x
184188
virtual void asum(const int N, const Dtype* x, Dtype* y);
@@ -192,12 +196,12 @@ class CPUDevice : public Device<Dtype> {
192196
virtual void scale(const int N, const Dtype alpha, const Dtype *x, Dtype* y);
193197

194198
virtual void im2col(const Dtype* data_im, const int channels,
195-
const int height, const int width, const int ksize, const int pad,
196-
const int stride, Dtype* data_col);
199+
const int height, const int width, const int ksize,
200+
const int pad, const int stride, Dtype* data_col);
197201

198202
virtual void col2im(const Dtype* data_col, const int channels,
199-
const int height, const int width, const int ksize, const int pad,
200-
const int stride, Dtype* data_im);
203+
const int height, const int width, const int ksize,
204+
const int pad, const int stride, Dtype* data_im);
201205
};
202206

203207
template<typename Dtype>
@@ -255,7 +259,7 @@ class GPUDevice : public Device<Dtype> {
255259
virtual Dtype dot(const int N, const Dtype* x, const Dtype* y);
256260

257261
virtual uint32_t hamming_distance(const int N, const Dtype* x,
258-
const Dtype* y);
262+
const Dtype* y);
259263

260264
// Returns the sum of the absolute values of the elements of vector x
261265
virtual void asum(const int N, const Dtype* x, Dtype* y);
@@ -269,12 +273,12 @@ class GPUDevice : public Device<Dtype> {
269273
virtual void scale(const int N, const Dtype alpha, const Dtype *x, Dtype* y);
270274

271275
virtual void im2col(const Dtype* data_im, const int channels,
272-
const int height, const int width, const int ksize, const int pad,
273-
const int stride, Dtype* data_col);
276+
const int height, const int width, const int ksize,
277+
const int pad, const int stride, Dtype* data_col);
274278

275279
virtual void col2im(const Dtype* data_col, const int channels,
276-
const int height, const int width, const int psize, const int pad,
277-
const int stride, Dtype* data_im);
280+
const int height, const int width, const int psize,
281+
const int pad, const int stride, Dtype* data_im);
278282
};
279283

280284
// Device factory function

src/caffe/devices/cpu_device.cpp

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ namespace caffe {
1919

2020
template<>
2121
void CPUDevice<float>::gemm(const CBLAS_TRANSPOSE TransA,
22-
const CBLAS_TRANSPOSE TransB, const int M,
23-
const int N, const int K, const float alpha,
24-
const float* A, const float* B,
25-
const float beta, float* C) {
22+
const CBLAS_TRANSPOSE TransB, const int M,
23+
const int N, const int K, const float alpha,
24+
const float* A, const float* B, const float beta,
25+
float* C) {
2626
int lda = (TransA == CblasNoTrans) ? K : M;
2727
int ldb = (TransB == CblasNoTrans) ? N : K;
2828
cblas_sgemm(CblasRowMajor, TransA, TransB, M, N, K, alpha, A, lda, B,
@@ -31,10 +31,10 @@ void CPUDevice<float>::gemm(const CBLAS_TRANSPOSE TransA,
3131

3232
template<>
3333
void CPUDevice<double>::gemm(const CBLAS_TRANSPOSE TransA,
34-
const CBLAS_TRANSPOSE TransB, const int M,
35-
const int N, const int K, const double alpha,
36-
const double* A, const double* B,
37-
const double beta, double* C) {
34+
const CBLAS_TRANSPOSE TransB, const int M,
35+
const int N, const int K, const double alpha,
36+
const double* A, const double* B,
37+
const double beta, double* C) {
3838
int lda = (TransA == CblasNoTrans) ? K : M;
3939
int ldb = (TransB == CblasNoTrans) ? N : K;
4040
cblas_dgemm(CblasRowMajor, TransA, TransB, M, N, K, alpha, A, lda, B,
@@ -43,41 +43,39 @@ void CPUDevice<double>::gemm(const CBLAS_TRANSPOSE TransA,
4343

4444
template<>
4545
void CPUDevice<float>::gemv(const CBLAS_TRANSPOSE TransA, const int M,
46-
const int N, const float alpha,
47-
const float* A, const float* x,
48-
const float beta, float* y) {
46+
const int N, const float alpha, const float* A,
47+
const float* x, const float beta, float* y) {
4948
cblas_sgemv(CblasRowMajor, TransA, M, N, alpha, A, N, x, 1, beta, y, 1);
5049
}
5150

5251
template<>
5352
void CPUDevice<double>::gemv(const CBLAS_TRANSPOSE TransA, const int M,
54-
const int N, const double alpha,
55-
const double* A, const double* x,
56-
const double beta, double* y) {
53+
const int N, const double alpha, const double* A,
54+
const double* x, const double beta, double* y) {
5755
cblas_dgemv(CblasRowMajor, TransA, M, N, alpha, A, N, x, 1, beta, y, 1);
5856
}
5957

6058
template<>
6159
void CPUDevice<float>::axpy(const int N, const float alpha, const float* X,
62-
float* Y) {
60+
float* Y) {
6361
cblas_saxpy(N, alpha, X, 1, Y, 1);
6462
}
6563

6664
template<>
6765
void CPUDevice<double>::axpy(const int N, const double alpha, const double* X,
68-
double* Y) {
66+
double* Y) {
6967
cblas_daxpy(N, alpha, X, 1, Y, 1);
7068
}
7169

7270
template<>
7371
void CPUDevice<float>::axpby(const int N, const float alpha, const float* X,
74-
const float beta, float* Y) {
72+
const float beta, float* Y) {
7573
cblas_saxpby(N, alpha, X, 1, beta, Y, 1);
7674
}
7775

7876
template<>
7977
void CPUDevice<double>::axpby(const int N, const double alpha, const double* X,
80-
const double beta, double* Y) {
78+
const double beta, double* Y) {
8179
cblas_daxpby(N, alpha, X, 1, beta, Y, 1);
8280
}
8381

@@ -148,61 +146,61 @@ void CPUDevice<double>::sqr(const int N, const double* a, double* y) {
148146

149147
template<>
150148
void CPUDevice<float>::add(const int N, const float* a, const float* b,
151-
float* y) {
149+
float* y) {
152150
vsAdd(N, a, b, y);
153151
}
154152

155153
template<>
156154
void CPUDevice<double>::add(const int N, const double* a, const double* b,
157-
double* y) {
155+
double* y) {
158156
vdAdd(N, a, b, y);
159157
}
160158

161159
template<>
162160
void CPUDevice<float>::sub(const int N, const float* a, const float* b,
163-
float* y) {
161+
float* y) {
164162
vsSub(N, a, b, y);
165163
}
166164

167165
template<>
168166
void CPUDevice<double>::sub(const int N, const double* a, const double* b,
169-
double* y) {
167+
double* y) {
170168
vdSub(N, a, b, y);
171169
}
172170

173171
template<>
174172
void CPUDevice<float>::mul(const int N, const float* a, const float* b,
175-
float* y) {
173+
float* y) {
176174
vsMul(N, a, b, y);
177175
}
178176

179177
template<>
180178
void CPUDevice<double>::mul(const int N, const double* a, const double* b,
181-
double* y) {
179+
double* y) {
182180
vdMul(N, a, b, y);
183181
}
184182

185183
template<>
186184
void CPUDevice<float>::div(const int N, const float* a, const float* b,
187-
float* y) {
185+
float* y) {
188186
vsDiv(N, a, b, y);
189187
}
190188

191189
template<>
192190
void CPUDevice<double>::div(const int N, const double* a, const double* b,
193-
double* y) {
191+
double* y) {
194192
vdDiv(N, a, b, y);
195193
}
196194

197195
template<>
198196
void CPUDevice<float>::powx(const int N, const float* a, const float b,
199-
float* y) {
197+
float* y) {
200198
vsPowx(N, a, b, y);
201199
}
202200

203201
template<>
204202
void CPUDevice<double>::powx(const int N, const double* a, const double b,
205-
double* y) {
203+
double* y) {
206204
vdPowx(N, a, b, y);
207205
}
208206

@@ -213,8 +211,8 @@ static Dtype _nextafter(const Dtype b) {
213211
}
214212

215213
template<typename Dtype>
216-
void CPUDevice<Dtype>::rng_uniform(const int N, const Dtype a,
217-
const Dtype b, Dtype* r) {
214+
void CPUDevice<Dtype>::rng_uniform(const int N, const Dtype a, const Dtype b,
215+
Dtype* r) {
218216
CHECK_GE(N, 0);
219217
CHECK(r);
220218
CHECK_LE(a, b);
@@ -228,7 +226,7 @@ void CPUDevice<Dtype>::rng_uniform(const int N, const Dtype a,
228226

229227
template<typename Dtype>
230228
void CPUDevice<Dtype>::rng_gaussian(const int N, const Dtype mu,
231-
const Dtype sigma, Dtype* r) {
229+
const Dtype sigma, Dtype* r) {
232230
CHECK_GE(N, 0);
233231
CHECK(r);
234232
CHECK_GT(sigma, 0);
@@ -256,7 +254,7 @@ void CPUDevice<Dtype>::rng_bernoulli(const int N, const Dtype p, int* r) {
256254

257255
template<typename Dtype>
258256
void CPUDevice<Dtype>::rng_bernoulli(const int N, const Dtype p,
259-
unsigned int* r) {
257+
unsigned int* r) {
260258
CHECK_GE(N, 0);
261259
CHECK(r);
262260
CHECK_GE(p, 0);
@@ -281,19 +279,19 @@ void CPUDevice<double>::exp(const int N, const double* a, double* y) {
281279

282280
template<>
283281
void CPUDevice<float>::dot(const int N, const float* x, const float* y,
284-
float* out) {
282+
float* out) {
285283
*out = cblas_sdot(N, x, 1, y, 1);
286284
}
287285

288286
template<>
289287
void CPUDevice<double>::dot(const int N, const double* x, const double* y,
290-
double* out) {
288+
double* out) {
291289
*out = cblas_ddot(N, x, 1, y, 1);
292290
}
293291

294292
template<>
295293
uint32_t CPUDevice<float>::hamming_distance(const int N, const float* x,
296-
const float* y) {
294+
const float* y) {
297295
uint32_t dist = 0;
298296
for (int i = 0; i < N; ++i) {
299297
dist += __builtin_popcount(static_cast<uint32_t>(x[i]) ^
@@ -366,22 +364,23 @@ void CPUDevice<Dtype>::fabs(const int N, const Dtype* x, Dtype* y) {
366364

367365
template<>
368366
void CPUDevice<float>::scale(const int N, const float alpha, const float *x,
369-
float* y) {
367+
float* y) {
370368
cblas_scopy(N, x, 1, y, 1);
371369
cblas_sscal(N, alpha, y, 1);
372370
}
373371

374372
template<>
375373
void CPUDevice<double>::scale(const int N, const double alpha, const double *x,
376-
double* y) {
374+
double* y) {
377375
cblas_dcopy(N, x, 1, y, 1);
378376
cblas_dscal(N, alpha, y, 1);
379377
}
380378

381379
template<typename Dtype>
382380
void CPUDevice<Dtype>::im2col(const Dtype* data_im, const int channels,
383-
const int height, const int width, const int ksize, const int pad,
384-
const int stride, Dtype* data_col) {
381+
const int height, const int width,
382+
const int ksize, const int pad, const int stride,
383+
Dtype* data_col) {
385384
int height_col = (height + 2 * pad - ksize) / stride + 1;
386385
int width_col = (width + 2 * pad - ksize) / stride + 1;
387386
int channels_col = channels * ksize * ksize;
@@ -405,8 +404,9 @@ void CPUDevice<Dtype>::im2col(const Dtype* data_im, const int channels,
405404

406405
template<typename Dtype>
407406
void CPUDevice<Dtype>::col2im(const Dtype* data_col, const int channels,
408-
const int height, const int width, const int ksize, const int pad,
409-
const int stride, Dtype* data_im) {
407+
const int height, const int width,
408+
const int ksize, const int pad, const int stride,
409+
Dtype* data_im) {
410410
memset(data_im, 0, sizeof(Dtype) * height * width * channels);
411411
int height_col = (height + 2 * pad - ksize) / stride + 1;
412412
int width_col = (width + 2 * pad - ksize) / stride + 1;

0 commit comments

Comments
 (0)