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

Method createPlugin

plugin/gridAnchorPlugin/gridAnchorPlugin.cpp:398–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396}
397
398IPluginV2Ext* GridAnchorBasePluginCreator::createPlugin(char const* name, PluginFieldCollection const* fc) noexcept
399{
400 try
401 {
402 float minScale = 0.2F, maxScale = 0.95F;
403 int32_t numLayers = 6;
404 std::vector<float> aspectRatios;
405 std::vector<int32_t> fMapShapes;
406 std::vector<float> layerVariances;
407 PluginField const* fields = fc->fields;
408
409 bool const isFMapRect = (kGRID_ANCHOR_PLUGIN_NAMES[1] == mPluginName);
410 for (int32_t i = 0; i < fc->nbFields; ++i)
411 {
412 char const* attrName = fields[i].name;
413 if (!strcmp(attrName, "numLayers"))
414 {
415 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32);
416 numLayers = static_cast<int32_t>(*(static_cast<int32_t const*>(fields[i].data)));
417 }
418 else if (!strcmp(attrName, "minSize"))
419 {
420 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32);
421 minScale = static_cast<float>(*(static_cast<float const*>(fields[i].data)));
422 }
423 else if (!strcmp(attrName, "maxSize"))
424 {
425 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32);
426 maxScale = static_cast<float>(*(static_cast<float const*>(fields[i].data)));
427 }
428 else if (!strcmp(attrName, "variance"))
429 {
430 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32);
431 int32_t size = fields[i].length;
432 layerVariances.reserve(size);
433 auto const* lVar = static_cast<float const*>(fields[i].data);
434 for (int32_t j = 0; j < size; j++)
435 {
436 layerVariances.push_back(*lVar);
437 lVar++;
438 }
439 }
440 else if (!strcmp(attrName, "aspectRatios"))
441 {
442 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32);
443 int32_t size = fields[i].length;
444 aspectRatios.reserve(size);
445 auto const* aR = static_cast<float const*>(fields[i].data);
446 for (int32_t j = 0; j < size; j++)
447 {
448 aspectRatios.push_back(*aR);
449 aR++;
450 }
451 }
452 else if (!strcmp(attrName, "featureMapShapes"))
453 {
454 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32);
455 int32_t size = fields[i].length;

Callers

nothing calls this directly

Calls 5

caughtErrorFunction · 0.85
c_strMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45
setPluginNamespaceMethod · 0.45

Tested by

no test coverage detected