Questions about the pool layer in TensorRT2.1

Hello,

I want parse the SegNet by TensorRT2.1,however when parse the pool layer in segnet,it occours the error"the top should be 1,but there are 2".And the pool layer in the prototxt is like this:
layer {
bottom: “conv1_2”
top: “pool1”
top: “pool1_mask”
name: “pool1”
type: “Pooling”
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}

And the pooling_layer.cpp in segnet :https://github.com/TimoSaemann/caffe-segnet-cudnn5/blob/master/src/caffe/layers/pooling_layer.cpp
The code of pooling_layer in segnet is almost the same as the code of this layer in Nvcaffe :https://github.com/alpesis-fork/NVCaffe/blob/master/src/caffe/layers/pooling_layer.cpp
So why the pool layer in this prototxt works in segnet but not supported by the TensorRT2.1?

Hi,

Could you check the definition of this pooling layer in the custom Caffe branch?

Usually, pooling layer has ONE input blob and ONE output blob.
This custom pooling layer has two output blobs: pool1 and pool1_mask, different from the general usage.

If the information of pool1_mask is essential, you may need to implement it with Plugin API:
Here is a sample for your reference: https://github.com/AastaNV/Face-Recognition

Thanks.

Hello.

I have checked the pooling layer of official caffe with the pooling layer of segnet,the code are almost the same.And  just as I said above,the code of pooling layer in Nvcaffe is also almost same as that in segnet. Besides, I tried to modify the pooling layer in lenet.prototxt privided by official caffe to like this:

layer {
name: “pool1”
type: “Pooling”
bottom: “conv1”
top: “pool1”
top: “pool1_mask”
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}

And then train the lenet, although the network cannot train right,but it initializes successfully.I think it means the pooling layer supports two tops in caffe. And in the source code of pooling layer of official caffe,there are top[0],and top[1]:
1:top[0]->Reshape(bottom[0]->num(), channels_, pooled_height_,
pooled_width_);
if (top.size() > 1) {
top[1]->ReshapeLike(*top[0]);
}
2: if (use_top_mask) {
top_mask = top[1]->mutable_cpu_data();
caffe_set(top_count, Dtype(-1), top_mask);
} else {
mask = max_idx_.mutable_cpu_data();
caffe_set(top_count, -1, mask);
}
I think it also proves the pooling layer of official caffe can support two tops.And I have checked the pooling layer code of nvcaffe,official caffe,and segnet are all the same,so why tensorrt2.1 cannot support?

Hi,

Usually, pooling layer has ONE input and ONE output.
From your error log, TensorRT also complains about this.

Check your prototxt first.
If the pool1_mask doesn’t be used elsewhere, remove it directly.

Please noticed that not all operations or layers of Caffe/TensorFlow are supported by TensorRT.
If you meet a non-supported layer, please implement it with Plugin API.

Thanks.

Hello,

I have tried to write a pooling layer with two tops in official caffe ,and it proves the network works.As the pooling layer in NVcaffe is same as official layer,why pooling layer in tensorrt2.1 cannot support two tops? Or the tensorrt2.1 doesn’t depend on nvcaffe?

Not all the Caffe/NvCaffe/TensorFlow operations are supported by TensorRT.

For available operations, please check our TensorRT document for detail:

1.1. TensorRT Layers

TensorRT is independent of other libraries and there is no dependency between Caffe(or NvCaffe) and TensorRT.
The only relationship is the model parser for users to import their model.

Thanks.