summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlinziyi <linziyi@sensetime.com>2018-01-18 19:07:45 (GMT)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>2018-01-29 01:05:26 (GMT)
commit25c217c1a49239bbcaf45aa6c60ab9f0354819bb (patch)
tree668221bad135a9493f48aa8924d0b7b957f6052d
parentbb4ffa4d440e8a9c452c410ad9db2ed7137c9f7d (diff)
downloadcaffe-25c217c1a49239bbcaf45aa6c60ab9f0354819bb.zip
caffe-25c217c1a49239bbcaf45aa6c60ab9f0354819bb.tar.gz
caffe-25c217c1a49239bbcaf45aa6c60ab9f0354819bb.tar.bz2
clear scratch use of loss bottom diffs
-rw-r--r--src/caffe/layers/sigmoid_cross_entropy_loss_layer.cu3
-rw-r--r--src/caffe/layers/softmax_loss_layer.cu2
2 files changed, 5 insertions, 0 deletions
diff --git a/src/caffe/layers/sigmoid_cross_entropy_loss_layer.cu b/src/caffe/layers/sigmoid_cross_entropy_loss_layer.cu
index b9877e6..14e247f 100644
--- a/src/caffe/layers/sigmoid_cross_entropy_loss_layer.cu
+++ b/src/caffe/layers/sigmoid_cross_entropy_loss_layer.cu
@@ -69,6 +69,9 @@ void SigmoidCrossEntropyLossLayer<Dtype>::Forward_gpu(
caffe_gpu_asum(count, loss_data, &loss);
normalizer_ = get_normalizer(normalization_, valid_count);
top[0]->mutable_cpu_data()[0] = loss / normalizer_;
+
+ caffe_gpu_set(bottom[0]->count(), Dtype(0), bottom[0]->mutable_gpu_diff());
+ caffe_gpu_set(bottom[1]->count(), Dtype(0), bottom[1]->mutable_gpu_diff());
}
template <typename Dtype>
diff --git a/src/caffe/layers/softmax_loss_layer.cu b/src/caffe/layers/softmax_loss_layer.cu
index 660e1b3..6c8db14 100644
--- a/src/caffe/layers/softmax_loss_layer.cu
+++ b/src/caffe/layers/softmax_loss_layer.cu
@@ -61,6 +61,8 @@ void SoftmaxWithLossLayer<Dtype>::Forward_gpu(
if (top.size() == 2) {
top[1]->ShareData(prob_);
}
+
+ caffe_gpu_set(bottom[0]->count(), Dtype(0), bottom[0]->mutable_gpu_diff());
}
template <typename Dtype>