TensorRT: Plugin parameter parse incorrectly
Description
custom plugin parameter incorrect when parameter number more than 10.
customPlugin = plugin_creator.create_plugin("customPluginA",
trt.PluginFieldCollection([
trt.PluginField("img_size",
np.array([768], dtype=np.float32),
trt.PluginFieldType.FLOAT32),
trt.PluginField("variances",
np.ascontiguousarray(
[0.1, 0.1, 0.05, 0.2, 0.2, 0.2],
dtype=np.float32),
trt.PluginFieldType.FLOAT32),
trt.PluginField("size_threshold",
np.array([15000], dtype=np.float32),
trt.PluginFieldType.FLOAT32),
trt.PluginField("out_size",
np.array([48], dtype=np.float32),
trt.PluginFieldType.FLOAT32),
trt.PluginField("threshold",
np.array([0.01], dtype=np.float32),
trt.PluginFieldType.FLOAT32),
trt.PluginField("high_size_count",
np.array([3], dtype=np.int32),
trt.PluginFieldType.INT32),
trt.PluginField("low_size_count",
np.array([8], dtype=np.int32),
trt.PluginFieldType.INT32),
trt.PluginField("nms_topk",
np.array([-1], dtype=np.int32),
trt.PluginFieldType.INT32),
trt.PluginField("clip", np.array([1], dtype=np.int8),
trt.PluginFieldType.INT8),
trt.PluginField("force_suppress",
np.array([1], dtype=np.int8),
trt.PluginFieldType.INT8),
trt.PluginField("nms_threshold",
np.array([0.00001], dtype=np.float32),
trt.PluginFieldType.FLOAT32),
trt.PluginField("center_bias",
np.array([0.4], dtype=np.float32),
trt.PluginFieldType.FLOAT32)
]))
out = network.add_plugin_v2([data, cls_prob, loc_pred, anchors], customPlugin)
img_size: 6.01021e-37
variances: 0.1 0.1 0.05 0.2 0.2 0.2
size_threshold: 6.00981e-37
out_size: 48
threshold: 0.01
high_size_cout: 3
low_size_count: 8
nms_topk: -1
clip: 1
force_suppress: 1
nms_threshold: 1e-05
center_bias: 0.4
the first and third parameters value are incorrect, and if I add one more the fourth parameter value will be incorrect as well. However if the parameter number less than 10, all parameters will correct. Does anyone have a clue?
Environment
TensorRT Version: TensorRT-6.0.1.5-cuda10.0 GPU Type: GeForce GTX 1080 Nvidia Driver Version: 430.26 CUDA Version: cuda10.0 CUDNN Version: 7.6 Operating System + Version: Ubuntu 18.04 Python Version (if applicable): python 3.6 TensorFlow Version (if applicable): PyTorch Version (if applicable): Baremetal or Container (if container which image + tag):
Relevant Files
Steps To Reproduce
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20
Hm, but if I separate that logic out to functions, I still get some issues:
Only the 2-step in-line method had correct values:
@rmccorm4 Sadly, this doesn’t work for my case 😦 Values are still strange.
I printed out pluginfield’s data attribute, and found something strange things (maybe…?)
All of plugin field’s address are same.
numpy version (1.14.0 ~ 1.18.1) didn’t work.
output values
Everyone makes those mistakes once in a while, thanks for sharing 🙂
I’m really shame… I just reuse a “variable i” in inner for loop when I debug.
Ah, and I also confirmed about this issue after fix my debug code. Only 2 step inline works fine.
@rmccorm4 Sorry… It was due to my misake. Everything works fine with 2-step inline. Thanks a lot!
Yeah, in the original issue I believe the issue occurs at 7/8 args. Will need to look into underlying issue there.
You can verify that in my script above by changing the 12 in
range(1, 12)
to different numbers.Glad it helped! If you get a chance to try the C++ API as well, that would be very helpful, but no worries if you can’t 🙂
@rmccorm4 OMG … Thanks soooooooo much again !!! I didn’t test with C++ api.
Here’s an interesting observation…
Initializing the PluginFieldCollection all in one step like in your example,
I see the bad behavior:
However, if you first create the list of plugin_fields, and then separately create a PluginFieldCollection from this list:
The output seems fine:
@Mengman @dhkim0225 looking into it now
@dhkim0225 No, I didn’t solve it. @rmccorm4 I update to TensorRT-7.0.0.11-cuda10.0 this problem still exists
@rmccorm4
here is my code
customPlugin.h
customPlugin.cpp
custom_plugin_test.py
makefile