How to create a plugin support input format::kHWC8?


I want to create a plugin that support input DataType::kHALF and TensorFormat::kHWC8.

Here’s my function:

bool MyPlugin::supportsFormatCombination(
int32_t pos, const PluginTensorDesc *inOut, int32_t nbInputs, int32_t nbOutputs)
// input and output must have the same dataType
return inOut[pos].type == DataType::kHALF &&
inOut[pos].format == TensorFormat::kLINEAR;

It works fine with kLINEAR.
But when use kHWC8 instead of kLINEAR, I got error:

[04/18/2021-17:44:56] [I] [TRT] Some tactics do not have sufficient workspace memory to run. Increasing workspace size may increase performance, please check verbose output.
[04/18/2021-17:46:21] [E] [TRT] …/rtSafe/cuda/cudaReformatRunner.cpp (251) - Assertion Error in combineDHtoH: 0 (nbSpatialDims == 3 && nbDims >= 5)
[04/18/2021-17:46:21] [E] Engine creation failed
[04/18/2021-17:46:21] [E] Engine set up failed.

Please refer to below links related custom plugin implementation and sample:


I have tried the examples in TensorRT/plugin at master · NVIDIA/TensorRT · GitHub, but all of them only support TensorFormat::kLINEAR and this leads to extra layers in network. Is there any way to write plugin support kHWC8?

Hi @807907950,

We request you to share issue reproducible scripts/model for better assistance.

Thank you.

Hi, I met the same problem. Do you solve it?

Hi,I upgrade my TensorRT to and solved.