Skip to content

Commit db72704

Browse files
committed
flownet2 patch: fix the data copy error for CPU/GPU mode respectively in DataAugmentationLayer.
1 parent bfc8ee7 commit db72704

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/caffe/layers/data_augmentation_layer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,11 @@ void DataAugmentationLayer<Dtype>::adjust_blobs(vector<Blob<Dtype>* > blobs)
175175
{
176176
// If using RGB mean, copy only RGB values (blob 2)
177177
Blob<Dtype> tmp; tmp.CopyFrom(*blobs[2], false,true);
178-
caffe_copy(this->blobs_[2]->count()*sizeof(float), tmp.mutable_cpu_data(), this->blobs_[2]->mutable_gpu_data());
179-
178+
#ifndef CPU_ONLY
179+
caffe_gpu_memcpy(this->blobs_[2]->count()*sizeof(float), tmp.mutable_gpu_data(), this->blobs_[2]->mutable_gpu_data());
180+
#else
181+
caffe_copy(this->blobs_[2]->count()*sizeof(float), tmp.mutable_cpu_data(), this->blobs_[2]->mutable_cpu_data());
182+
#endif
180183
Dtype* data_mean_per_channel_cpu = this->blobs_[2]->mutable_cpu_data();
181184
for(int i=0; i<this->blobs_[2]->count(); i++)
182185
LOG(INFO) << "recovered mean value " << data_mean_per_channel_cpu[i];

0 commit comments

Comments
 (0)