Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit 187e248

Browse files
committed
Fix bug scale_layer when cpu forward
1 parent ed05614 commit 187e248

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/caffe/layers/scale_layer.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ void ScaleLayer<Dtype>::Forward_cpu(
117117
// Note that this is only necessary for Backward; we could skip this if not
118118
// doing Backward, but Caffe currently provides no way of knowing whether
119119
// we'll need to do Backward at the time of the Forward call.
120-
caffe_copy(bottom[0]->count(), bottom[0]->cpu_data(),
121-
temp_.mutable_cpu_data());
120+
const bool scale_param = (bottom.size() == 1);
121+
if (!scale_param || (scale_param && this->param_propagate_down_[0])) {
122+
caffe_copy(bottom[0]->count(), bottom[0]->gpu_data(),
123+
temp_.mutable_cpu_data());
124+
}
122125
}
123126
const Dtype* scale_data =
124127
((bottom.size() > 1) ? bottom[1] : this->blobs_[0].get())->cpu_data();

0 commit comments

Comments
 (0)