From 839b0502648a5dcf056c3f4a6ace1d0198e6b03e Mon Sep 17 00:00:00 2001 From: Evan Shelhamer Date: Fri, 4 Mar 2016 15:35:16 -0800 Subject: [PATCH] share columnation buffers for convolution to save memory share the im2col / col2im buffers among convolution + deconvolution layers by making the buffer a static member. @longjon deserves all the credit for the reshaping #594 and this patch. --- include/caffe/layers/base_conv_layer.hpp | 4 +++- src/caffe/layers/base_conv_layer.cpp | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/caffe/layers/base_conv_layer.hpp b/include/caffe/layers/base_conv_layer.hpp index 0160a833dd2..8cdbd2d1b43 100644 --- a/include/caffe/layers/base_conv_layer.hpp +++ b/include/caffe/layers/base_conv_layer.hpp @@ -165,7 +165,9 @@ class BaseConvolutionLayer : public Layer { int col_offset_; int output_offset_; - Blob col_buffer_; + // N.B. sharing the col buffer reduces memory but interferes with + // ND conv and parallelism + static Blob col_buffer_; Blob bias_multiplier_; }; diff --git a/src/caffe/layers/base_conv_layer.cpp b/src/caffe/layers/base_conv_layer.cpp index 4a4c68e009a..8a7b5e8c8d3 100644 --- a/src/caffe/layers/base_conv_layer.cpp +++ b/src/caffe/layers/base_conv_layer.cpp @@ -8,6 +8,9 @@ namespace caffe { +template +Blob BaseConvolutionLayer::col_buffer_; + template void BaseConvolutionLayer::LayerSetUp(const vector*>& bottom, const vector*>& top) {