From 187e24826966d5ed54bfdbf98917de8b1f4a630a Mon Sep 17 00:00:00 2001 From: wyg1997 Date: Wed, 30 Oct 2019 16:08:52 +0800 Subject: [PATCH] Fix bug scale_layer when cpu forward --- src/caffe/layers/scale_layer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/caffe/layers/scale_layer.cpp b/src/caffe/layers/scale_layer.cpp index aa90848eda0..174189eb467 100644 --- a/src/caffe/layers/scale_layer.cpp +++ b/src/caffe/layers/scale_layer.cpp @@ -117,8 +117,11 @@ void ScaleLayer::Forward_cpu( // Note that this is only necessary for Backward; we could skip this if not // doing Backward, but Caffe currently provides no way of knowing whether // we'll need to do Backward at the time of the Forward call. - caffe_copy(bottom[0]->count(), bottom[0]->cpu_data(), - temp_.mutable_cpu_data()); + const bool scale_param = (bottom.size() == 1); + if (!scale_param || (scale_param && this->param_propagate_down_[0])) { + caffe_copy(bottom[0]->count(), bottom[0]->gpu_data(), + temp_.mutable_cpu_data()); + } } const Dtype* scale_data = ((bottom.size() > 1) ? bottom[1] : this->blobs_[0].get())->cpu_data();