| 439 | } |
| 440 | |
| 441 | IPluginV2DynamicExt* EfficientNMSPluginCreator::createPlugin(char const* name, PluginFieldCollection const* fc) noexcept |
| 442 | { |
| 443 | try |
| 444 | { |
| 445 | PLUGIN_VALIDATE(fc != nullptr); |
| 446 | PluginField const* fields = fc->fields; |
| 447 | PLUGIN_VALIDATE(fields != nullptr); |
| 448 | plugin::validateRequiredAttributesExist({"score_threshold", "iou_threshold", "max_output_boxes", |
| 449 | "background_class", "score_activation", "box_coding"}, |
| 450 | fc); |
| 451 | for (int32_t i{0}; i < fc->nbFields; ++i) |
| 452 | { |
| 453 | char const* attrName = fields[i].name; |
| 454 | if (!strcmp(attrName, "score_threshold")) |
| 455 | { |
| 456 | PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32); |
| 457 | auto const scoreThreshold = *(static_cast<float const*>(fields[i].data)); |
| 458 | PLUGIN_VALIDATE(scoreThreshold >= 0.0F); |
| 459 | mParam.scoreThreshold = scoreThreshold; |
| 460 | } |
| 461 | if (!strcmp(attrName, "iou_threshold")) |
| 462 | { |
| 463 | PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32); |
| 464 | auto const iouThreshold = *(static_cast<float const*>(fields[i].data)); |
| 465 | PLUGIN_VALIDATE(iouThreshold > 0.0F); |
| 466 | mParam.iouThreshold = iouThreshold; |
| 467 | } |
| 468 | if (!strcmp(attrName, "max_output_boxes")) |
| 469 | { |
| 470 | PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32); |
| 471 | auto const numOutputBoxes = *(static_cast<int32_t const*>(fields[i].data)); |
| 472 | PLUGIN_VALIDATE(numOutputBoxes > 0); |
| 473 | mParam.numOutputBoxes = numOutputBoxes; |
| 474 | } |
| 475 | if (!strcmp(attrName, "background_class")) |
| 476 | { |
| 477 | PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32); |
| 478 | mParam.backgroundClass = *(static_cast<int32_t const*>(fields[i].data)); |
| 479 | } |
| 480 | if (!strcmp(attrName, "score_activation")) |
| 481 | { |
| 482 | auto const scoreSigmoid = *(static_cast<int32_t const*>(fields[i].data)); |
| 483 | PLUGIN_VALIDATE(scoreSigmoid == 0 || scoreSigmoid == 1); |
| 484 | mParam.scoreSigmoid = static_cast<bool>(scoreSigmoid); |
| 485 | } |
| 486 | if (!strcmp(attrName, "class_agnostic")) |
| 487 | { |
| 488 | auto const classAgnostic = *(static_cast<int32_t const*>(fields[i].data)); |
| 489 | PLUGIN_VALIDATE(classAgnostic == 0 || classAgnostic == 1); |
| 490 | mParam.classAgnostic = static_cast<bool>(classAgnostic); |
| 491 | } |
| 492 | if (!strcmp(attrName, "box_coding")) |
| 493 | { |
| 494 | PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32); |
| 495 | auto const boxCoding = *(static_cast<int32_t const*>(fields[i].data)); |
| 496 | PLUGIN_VALIDATE(boxCoding == 0 || boxCoding == 1); |
| 497 | mParam.boxCoding = boxCoding; |
| 498 | } |
nothing calls this directly
no test coverage detected