Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit fd692c4

Browse files
committed
fix build error caused by USE_OPENMP being OFF
1 parent ca7d58f commit fd692c4

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

src/caffe/data_transformer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ void DataTransformer<Dtype>::Transform(const Datum& datum, Dtype* transformed_da
217217
mean = data_mean_.mutable_cpu_data();
218218
}
219219
if (has_mean_values) {
220+
#ifdef _OPENMP
220221
#pragma omp critical
222+
#endif
221223
{
222224
CHECK(mean_values_.size() == 1 || mean_values_.size() == datum_channels) <<
223225
"Specify either 1 mean_value or as many as channels: " << datum_channels;
@@ -417,7 +419,9 @@ void DataTransformer<Dtype>::Transform(const Datum& datum_in,
417419
mean = data_mean_.mutable_cpu_data();
418420
}
419421
if (has_mean_values) {
422+
#ifdef _OPENMP
420423
#pragma omp critical
424+
#endif
421425
{
422426
CHECK(mean_values_.size() == 1 || mean_values_.size() == datum_channels) <<
423427
"Specify either 1 mean_value or as many as channels: " << datum_channels;
@@ -1023,7 +1027,9 @@ void DataTransformer<Dtype>::Transform(const cv::Mat& cv_img_in,
10231027
mean = data_mean_.mutable_cpu_data();
10241028
}
10251029
if (has_mean_values) {
1030+
#ifdef _OPENMP
10261031
#pragma omp critical
1032+
#endif
10271033
{
10281034
CHECK(mean_values_.size() == 1 || mean_values_.size() == img_channels) <<
10291035
"Specify either 1 mean_value or as many as channels: " << img_channels;
@@ -1126,7 +1132,9 @@ void DataTransformer<Dtype>::TransformInv(const Dtype* data, cv::Mat* cv_img,
11261132
mean = data_mean_.mutable_cpu_data();
11271133
}
11281134
if (has_mean_values) {
1135+
#ifdef _OPENMP
11291136
#pragma omp critical
1137+
#endif
11301138
{
11311139
CHECK(mean_values_.size() == 1 || mean_values_.size() == channels) <<
11321140
"Specify either 1 mean_value or as many as channels: " << channels;
@@ -1261,7 +1269,9 @@ void DataTransformer<Dtype>::ExpandImage(const cv::Mat& img,
12611269
}
12621270
}
12631271
if (has_mean_values) {
1272+
#ifdef _OPENMP
12641273
#pragma omp critical
1274+
#endif
12651275
{
12661276
CHECK(mean_values_.size() == 1 || mean_values_.size() == img_channels) <<
12671277
"Specify either 1 mean_value or as many as channels: " << img_channels;

src/caffe/layers/mkldnn_convolution_layer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,9 @@ void MKLDNNConvolutionLayer<Dtype>::InitConvolutionFwd(const vector<Blob<Dtype>*
350350
}
351351
std::vector<float> scales(count);
352352
float scale;
353+
#ifdef _OPENMP
353354
#pragma omp parallel for if (count > 1)
355+
#endif
354356
for(int i=0; i<count; i++){
355357
if (this->scale_params_[i] == 0.0)
356358
scale = this->scale_out_[0] * coeff1;
@@ -505,7 +507,9 @@ void MKLDNNConvolutionLayer<Dtype>::InitConvolutionFwd(const vector<Blob<Dtype>*
505507
reorder_mask = (g!= 1) ? (1<<1)+(1<<0) : 1<<0;
506508
}
507509
std::vector<float> scale_weight(count);
510+
#ifdef _OPENMP
508511
#pragma omp parallel for if (count > 1)
512+
#endif
509513
for(int i=0; i<count; i++){
510514
scale_weight[i] = this->scale_params_[i];
511515
}
@@ -528,7 +532,9 @@ void MKLDNNConvolutionLayer<Dtype>::InitConvolutionFwd(const vector<Blob<Dtype>*
528532
reorder_mask = 1<<0;
529533
}
530534
std::vector<float> scale_bias(count);
535+
#ifdef _OPENMP
531536
#pragma omp parallel for if (count > 1)
537+
#endif
532538
for(int i=0; i<count; i++){
533539
if (this->scale_params_[i] == 0.0)
534540
scale_bias[i] = 1.0;

src/caffe/layers/permute_layer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ template <typename Dtype>
4646
void Permute(const int count, Dtype* bottom_data, const bool forward,
4747
const int* permute_order, const int* old_steps, const int* new_steps,
4848
const int num_axes, Dtype* top_data) {
49+
#ifdef _OPENMP
4950
#pragma omp parallel for
51+
#endif
5052
for (int i = 0; i < count; ++i) {
5153
int old_idx = 0;
5254
int idx = i;

src/caffe/layers/prelu_layer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ void PReLULayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
118118
// if channel_shared, channel index in the following computation becomes
119119
// always zero.
120120
const int div_factor = channel_shared_ ? channels : 1;
121+
#ifdef _OPENMP
121122
#pragma omp parallel for
123+
#endif
122124
for (long i = 0; i < count; ++i) {
123125
long c = (i / dim) % channels / div_factor;
124126
top_data[i] = std::max(bottom_data[i], Dtype(0))
@@ -160,7 +162,9 @@ void PReLULayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,
160162
// Propagate to bottom
161163
if (propagate_down[0]) {
162164
Dtype* bottom_diff = bottom[0]->mutable_cpu_diff();
165+
#ifdef _OPENMP
163166
#pragma omp parallel for
167+
#endif
164168
for (long i = 0; i < count; ++i) {
165169
long c = (i / dim) % channels / div_factor;
166170
bottom_diff[i] = top_diff[i] * ((bottom_data[i] > 0)

src/caffe/mkldnn_memory.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ void MKLDNNMemoryDescriptorBase<Dtype>::create_reorder_descriptors(std::vector<f
9090
int count = scale.size();
9191
if ( *_usr_memory_pd != *_prv_memory_pd) {
9292
std::vector<float> scales_u2p(count);
93+
#ifdef _OPENMP
9394
#pragma omp parallel for if (count > 1)
95+
#endif
9496
for(int i=0; i < count; i++){
9597
scales_u2p[i] = scale[i];
9698
}
@@ -100,7 +102,9 @@ void MKLDNNMemoryDescriptorBase<Dtype>::create_reorder_descriptors(std::vector<f
100102
new reorder::primitive_desc(*_usr_memory_pd, *_prv_memory_pd, attri));
101103

102104
std::vector<float> scales_p2u(count);
105+
#ifdef _OPENMP
103106
#pragma omp parallel for if (count > 1)
107+
#endif
104108
for(int i=0; i < count; i++){
105109
scales_p2u[i] = (1. / scale[i]);
106110
}
@@ -120,7 +124,9 @@ void MKLDNNMemoryDescriptorBase<Dtype>::create_reorder_descriptors(std::vector<f
120124
}else{
121125
std::vector<float> scales_e2p(count);
122126
float shift_scale;
127+
#ifdef _OPENMP
123128
#pragma omp parallel for if (count > 1)
129+
#endif
124130
for(int i=0; i < count; i++){
125131
shift_scale = scale[i] / scale_ext[i]; //fp32->int8 blob_prv_mkldnn_mem_descr->get_scale() will always be 0 ?
126132
scales_e2p[i] = shift_scale;

src/caffe/multinode/mn_activation_layer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ void MnActivationLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,
206206
template <typename Dtype>
207207
void MnActivationLayer<Dtype>::Unpack(const Dtype *src, int N, int C, int HW, int numC, Dtype *dst) {
208208
int dstC = numC * C;
209+
#ifdef _OPENMP
209210
#pragma omp parallel for collapse (2)
211+
#endif
210212
for (int iN = 0; iN < N; iN++) {
211213
for (int iC = 0; iC < dstC; iC++) {
212214
int iSrc = iC / C;
@@ -223,7 +225,9 @@ template <typename Dtype>
223225
void MnActivationLayer<Dtype>::Pack(const Dtype *src, Dtype *dst, int N, int C, int HW, int numC) {
224226
int srcC = numC * C;
225227
for (int iDst = 0; iDst < numC; iDst++) {
228+
#ifdef _OPENMP
226229
#pragma omp parallel for collapse (2)
230+
#endif
227231
for (int iN = 0; iN < N; iN++) {
228232
for (int iC = 0; iC < C; iC++) {
229233
int iSrcC = iDst * C + iC;

0 commit comments

Comments
 (0)