caffe
caffe copied to clipboard
Add 3dUnet Support
This patch adds 3d support to all the layers needed to run 3dUnet in inference.
For others trying to run 3dUnet on caffe, you will run into two issues.
- Caffe doesn't support asymetric padding. As a functional workaround, do pad:2 convolution followed by 3 slice layers.
- Caffe doesn't have a tensorflow like Upsampling3D layer. As a functional workaround use Caffe Deconvolution layer with kernel size=4, stride=2. You may need to add Reshape layers before and after like this -> reshape_param { shape { dim: -1 dim: 1 dim: 0 dim: 0 dim: 0 } }
Travis builds look like they have been broken for months.
This should fix the default build target;
diff --git a/src/caffe/layer_factory.cpp b/src/caffe/layer_factory.cpp
index 0218d96..0bbc406 100644
--- a/src/caffe/layer_factory.cpp
+++ b/src/caffe/layer_factory.cpp
@@ -88,7 +88,7 @@ shared_ptr<Layer<Dtype> > GetConvolutionLayer(
ConvolutionParameter conv_param = param.convolution_param();
ConvolutionParameter_Engine engine = conv_param.engine();
-#if defined(USE_CUDNN) || defined(MKL2017_SUPPORTED) || defined(MKLDNN_SUPPORTED)
+#if defined(USE_CUDNN) || defined(MKL2017_SUPPORTED)
bool use_dilation = false;
for (int i = 0; i < conv_param.dilation_size(); ++i) {
if (conv_param.dilation(i) > 1) {
your patch looks good to me except some minor comments.
-
some if statements have no else ending, such as belows. it should have compiler warning and causes compile process break. I will add assertion for such case.
if(tensor_size == 4) { src_mfmt = memory::format::nchw; } else if(tensor_size == 5) { src_mfmt = memory::format::ncdhw; }
-
I am not quite sure why this is problem. could you let me know the reproduce steps?
diff --git a/src/caffe/layer_factory.cpp b/src/caffe/layer_factory.cpp -#if defined(USE_CUDNN) || defined(MKL2017_SUPPORTED) || defined(MKLDNN_SUPPORTED) +#if defined(USE_CUDNN) || defined(MKL2017_SUPPORTED)
PS: you PR will be merged to next release by manually. thanks for your effort.
your patch looks good to me except some minor comments.
1. some if statements have no else ending, such as belows. it should have compiler warning and causes compile process break. I will add assertion for such case. if(tensor_size == 4) { src_mfmt = memory::format::nchw; } else if(tensor_size == 5) { src_mfmt = memory::format::ncdhw; }
If i recall correctly, there is a check earlier in the code to make sure tensor is >= 4 and <= 5 so there are no other possibilities in this if statement. It could just be written as else (instead of else if) and the result will be the same. I chose to write it as "else if" to be more explicit.
2. I am not quite sure why this is problem. could you let me know the reproduce steps?
diff --git a/src/caffe/layer_factory.cpp b/src/caffe/layer_factory.cpp -#if defined(USE_CUDNN) || defined(MKL2017_SUPPORTED) || defined(MKLDNN_SUPPORTED) +#if defined(USE_CUDNN) || defined(MKL2017_SUPPORTED)
This has nothing to do with my PR. I just noticed you have some build issues with Travis and this patch will help. Look at the errors in the default build target for Travis.
PS: you PR will be merged to next release by manually. thanks for your effort.
Thanks. Please update me when its merged.