From 1582377a3d3917342f128b9f2a5b889c7d953f31 Mon Sep 17 00:00:00 2001 From: Kang Kim Date: Fri, 27 Nov 2015 21:57:51 +0900 Subject: [PATCH] Prevent in-place computation in ReshapeLayer and FlattenLayer --- src/caffe/layers/flatten_layer.cpp | 2 ++ src/caffe/layers/reshape_layer.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/caffe/layers/flatten_layer.cpp b/src/caffe/layers/flatten_layer.cpp index d831fb5c6b5..87cabfaed2f 100644 --- a/src/caffe/layers/flatten_layer.cpp +++ b/src/caffe/layers/flatten_layer.cpp @@ -7,6 +7,8 @@ namespace caffe { template void FlattenLayer::Reshape(const vector*>& bottom, const vector*>& 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( diff --git a/src/caffe/layers/reshape_layer.cpp b/src/caffe/layers/reshape_layer.cpp index 8659049b528..9a34a2587b0 100644 --- a/src/caffe/layers/reshape_layer.cpp +++ b/src/caffe/layers/reshape_layer.cpp @@ -7,6 +7,8 @@ namespace caffe { template void ReshapeLayer::LayerSetUp(const vector*>& bottom, const vector*>& 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();