| 663 | } |
| 664 | |
| 665 | IPluginV2Ext* 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 | } |
nothing calls this directly
no test coverage detected