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

Method createPlugin

plugin/batchedNMSPlugin/batchedNMSPlugin.cpp:665–754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

663}
664
665IPluginV2Ext* BatchedNMSPluginCreator::createPlugin(char const* name, PluginFieldCollection const* fc) noexcept
666{
667 try
668 {
669 NMSParameters params;
670 PluginField const* fields = fc->fields;
671 bool clipBoxes = true;
672 int32_t scoreBits = 16;
673 bool caffeSemantics = true;
674
675 std::set<std::string> requiredFields{
676 "shareLocation",
677 "backgroundLabelId",
678 "numClasses",
679 "topK",
680 "keepTopK",
681 "scoreThreshold",
682 "iouThreshold",
683 };
684 plugin::validateRequiredAttributesExist(requiredFields, fc);
685
686 for (int32_t i = 0; i < fc->nbFields; ++i)
687 {
688 char const* attrName = fields[i].name;
689 if (!strcmp(attrName, "shareLocation"))
690 {
691 params.shareLocation = *(static_cast<bool const*>(fields[i].data));
692 }
693 else if (!strcmp(attrName, "backgroundLabelId"))
694 {
695 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32);
696 params.backgroundLabelId = *(static_cast<int32_t const*>(fields[i].data));
697 }
698 else if (!strcmp(attrName, "numClasses"))
699 {
700 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32);
701 params.numClasses = *(static_cast<int32_t const*>(fields[i].data));
702 }
703 else if (!strcmp(attrName, "topK"))
704 {
705 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32);
706 params.topK = *(static_cast<int32_t const*>(fields[i].data));
707 }
708 else if (!strcmp(attrName, "keepTopK"))
709 {
710 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32);
711 params.keepTopK = *(static_cast<int32_t const*>(fields[i].data));
712 }
713 else if (!strcmp(attrName, "scoreThreshold"))
714 {
715 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32);
716 params.scoreThreshold = *(static_cast<float const*>(fields[i].data));
717 }
718 else if (!strcmp(attrName, "iouThreshold"))
719 {
720 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32);
721 params.iouThreshold = *(static_cast<float const*>(fields[i].data));
722 }

Callers

nothing calls this directly

Calls 7

caughtErrorFunction · 0.85
setClipParamMethod · 0.80
setCaffeSemanticsMethod · 0.80
c_strMethod · 0.80
setScoreBitsMethod · 0.45
setPluginNamespaceMethod · 0.45

Tested by

no test coverage detected