MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / createPlugin

Method createPlugin

plugin/detectionLayerPlugin/detectionLayerPlugin.cpp:61–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61IPluginV2Ext* DetectionLayerPluginCreator::createPlugin(char const* /*name*/, PluginFieldCollection const* fc) noexcept
62{
63 try
64 {
65 PLUGIN_VALIDATE(fc != nullptr);
66 plugin::validateRequiredAttributesExist({"num_classes", "keep_topk", "score_threshold", "iou_threshold"}, fc);
67 PluginField const* fields = fc->fields;
68 for (int32_t i = 0; i < fc->nbFields; ++i)
69 {
70 char const* attrName = fields[i].name;
71 if (!strcmp(attrName, "num_classes"))
72 {
73 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32);
74 mNbClasses = *(static_cast<int32_t const*>(fields[i].data));
75 }
76 if (!strcmp(attrName, "keep_topk"))
77 {
78 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32);
79 mKeepTopK = *(static_cast<int32_t const*>(fields[i].data));
80 }
81 if (!strcmp(attrName, "score_threshold"))
82 {
83 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32);
84 mScoreThreshold = *(static_cast<float const*>(fields[i].data));
85 }
86 if (!strcmp(attrName, "iou_threshold"))
87 {
88 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32);
89 mIOUThreshold = *(static_cast<float const*>(fields[i].data));
90 }
91 }
92 return new DetectionLayer(mNbClasses, mKeepTopK, mScoreThreshold, mIOUThreshold);
93 }
94 catch (std::exception const& e)
95 {
96 caughtError(e);
97 }
98 return nullptr;
99}
100
101IPluginV2Ext* DetectionLayerPluginCreator::deserializePlugin(
102 char const* /*name*/, void const* data, size_t length) noexcept

Callers

nothing calls this directly

Calls 2

caughtErrorFunction · 0.85

Tested by

no test coverage detected