Prevent in-place computation in ReshapeLayer and FlattenLayer
authorKang Kim <kkhoot@gmail.com>
Fri, 27 Nov 2015 12:57:51 +0000 (21:57 +0900)
committerJeff Donahue <jeff.donahue@gmail.com>
Tue, 26 Jan 2016 18:00:43 +0000 (10:00 -0800)
src/caffe/layers/flatten_layer.cpp
src/caffe/layers/reshape_layer.cpp

index 651507e..d4ab393 100644 (file)
@@ -7,6 +7,8 @@ namespace caffe {
 template <typename Dtype>
 void FlattenLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
       const vector<Blob<Dtype>*>& top) {
+  CHECK_NE(top[0], bottom[0]) << this->type() << " Layer does not "
+      "allow in-place computation.";
   const int start_axis = bottom[0]->CanonicalAxisIndex(
       this->layer_param_.flatten_param().axis());
   const int end_axis = bottom[0]->CanonicalAxisIndex(
index 82339f7..45dd090 100644 (file)
@@ -7,6 +7,8 @@ namespace caffe {
 template <typename Dtype>
 void ReshapeLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
     const vector<Blob<Dtype>*>& top) {
+  CHECK_NE(top[0], bottom[0]) << this->type() << " Layer does not "
+      "allow in-place computation.";
   inferred_axis_ = -1;
   copy_axes_.clear();
   const BlobShape& top_blob_shape = this->layer_param_.reshape_param().shape();