From 396da71569124a2362efe034764fffd679f51f00 Mon Sep 17 00:00:00 2001 From: J Yegerlehner Date: Sun, 7 Sep 2014 21:46:38 -0500 Subject: [PATCH 1/2] Repair crash in conv_layer due to weight pointer being NULL. --- src/caffe/layers/conv_layer.cpp | 3 +++ src/caffe/layers/conv_layer.cu | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/caffe/layers/conv_layer.cpp b/src/caffe/layers/conv_layer.cpp index 1a1248f3..be7a5740 100644 --- a/src/caffe/layers/conv_layer.cpp +++ b/src/caffe/layers/conv_layer.cpp @@ -203,6 +203,9 @@ void ConvolutionLayer::Backward_cpu(const vector*>& top, } // gradient w.r.t. bottom data, if necessary if (propagate_down[i]) { + if(weight==NULL) { + weight = this->blobs_[0]->cpu_data(); + } for (int g = 0; g < group_; ++g) { caffe_cpu_gemm(CblasTrans, CblasNoTrans, K_, N_, M_, (Dtype)1., weight + weight_offset * g, diff --git a/src/caffe/layers/conv_layer.cu b/src/caffe/layers/conv_layer.cu index f7f393ba..02cfdb3b 100644 --- a/src/caffe/layers/conv_layer.cu +++ b/src/caffe/layers/conv_layer.cu @@ -96,6 +96,9 @@ void ConvolutionLayer::Backward_gpu(const vector*>& top, } // gradient w.r.t. bottom data, if necessary if (propagate_down[i]) { + if (weight == NULL) { + weight = this->blobs_[0]->gpu_data(); + } for (int g = 0; g < group_; ++g) { caffe_gpu_gemm(CblasTrans, CblasNoTrans, K_, N_, M_, (Dtype)1., weight + weight_offset * g, From a739cdadbbca18e5d7c4f97b144e9cda8503037a Mon Sep 17 00:00:00 2001 From: J Yegerlehner Date: Sun, 7 Sep 2014 23:10:33 -0500 Subject: [PATCH 2/2] Fix more lint. --- src/caffe/layers/conv_layer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/caffe/layers/conv_layer.cpp b/src/caffe/layers/conv_layer.cpp index be7a5740..1d3686b9 100644 --- a/src/caffe/layers/conv_layer.cpp +++ b/src/caffe/layers/conv_layer.cpp @@ -203,7 +203,7 @@ void ConvolutionLayer::Backward_cpu(const vector*>& top, } // gradient w.r.t. bottom data, if necessary if (propagate_down[i]) { - if(weight==NULL) { + if (weight == NULL) { weight = this->blobs_[0]->cpu_data(); } for (int g = 0; g < group_; ++g) {