Can I plugin a layer with two output by TensorRT-2.1?

Hello,

I want to plugin a layer with two output,but the getOutputDimensions() seems just returns only one output tensor,so how to wirte the codes to returns two output tensors?

Hi,

In our face_recognition sample, there is a plugin layer with two output tensor:
https://github.com/AastaNV/Face-Recognition/blob/master/pluginImplement.cpp#L293

The basic idea is:
1. Assign the output tensor number in getNbOutputs()
2. Check index value to find out which output dimension is queried.

getOutputDimensions(int <b>index</b>, const Dims* inputs, int nbInputDims)

Thanks.

Hello,

Thanks a lot for your reply.Besides,I have another question,I’m very sure of the mean of size in Constructor,such as:

1、 RecognitionLayer::RecognitionLayer(FunctionType t, const void* buffer, size_t size)
{
assert(size==(sizeof(int)));
const int* d = reinterpret_cast<const int*>(buffer);

classNum = d[0];
type = t;

}

2、 DataRoiLayer::DataRoiLayer(const void* buffer, size_t size)
{
assert(size==(6sizeof(int)));
const int
d = reinterpret_cast<const int*>(buffer);
Reshape(const void* buffer, size_t size)
{
printf(“Reshape size is %d\n”,size);//=8
assert(size == sizeof(mCopySize));
mCopySize = reinterpret_cast<const size_t>(buffer);
}
dimsData = DimsCHW{d[0], d[1], d[2]};
dimsRoi = DimsCHW{d[3], d[4], d[5]};
}

3、 BboxMergeLayer::BboxMergeLayer(const void* buffer, size_t size)
{
assert(size==(9sizeof(int)));
const int
d = reinterpret_cast<const int*>(buffer);

dimsData = DimsCHW{d[0], d[1], d[2]};
dimsConf = DimsCHW{d[3], d[4], d[5]};
dimsBbox = DimsCHW{d[6], d[7], d[8]};

}

4、 Reshape(const void* buffer, size_t size)
{
printf(“Reshape size is %d\n”,size);//=8
assert(size == sizeof(mCopySize));
mCopySize = reinterpret_cast<const size_t>(buffer);
}

So what is the mean of size? How to find its value? Thanks.

Sorry ,I have pasted something wrong in 2.DataRoiLayer::DataRoiLayer,the right code is :
2、DataRoiLayer::DataRoiLayer(const void* buffer, size_t size)
{
assert(size==(6sizeof(int)));
const int
d = reinterpret_cast<const int*>(buffer);

dimsData  = DimsCHW{d[0], d[1], d[2]};
dimsRoi   = DimsCHW{d[3], d[4], d[5]};

}

Hi,

When creating TensorRT layer, you need to restore the serialized parameter first.
size indicates the amount of serialized data.

For example

DataRoiLayer::DataRoiLayer(const void* buffer, size_t size)
{
    assert(size==(6*sizeof(int)));
    const int* d = reinterpret_cast<const int*>(buffer);

    dimsData  = DimsCHW{d[0], d[1], d[2]};
    dimsRoi   = DimsCHW{d[3], d[4], d[5]};
}
...
size_t DataRoiLayer::getSerializationSize()
{
    return 6*sizeof(int);
}

void DataRoiLayer::serialize(void* buffer)
{
    int* d = reinterpret_cast<int*>(buffer);
    d[0] = dimsData.c(); d[1] = dimsData.h(); d[2] = dimsData.w();
    d[3] = dimsRoi.c();  d[4] = dimsRoi.h();  d[5] = dimsRoi.w();
}

Thanks.

Hi. Could you please be much more specific about what you mean be “the amount of serialized data”? Do you mean all the weights, measured in bytes? All the weights, all the plugin classes parameters? What do you mean? Do you have some clear documentation that you can point me too?

Hi,

We have some tutorial and sample for plugin layer:
Tutorial: [url]https://docs.nvidia.com/deeplearning/sdk/tensorrt-developer-guide/index.html#plugin_sample[/url]
Sample: GitHub - AastaNV/Face-Recognition: Demonstrate Plugin API for TensorRT2.1

Thanks.