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

Method createPlugin

plugin/priorBoxPlugin/priorBoxPlugin.cpp:402–523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402IPluginV2Ext* PriorBoxPluginCreator::createPlugin(char const* /*name*/, PluginFieldCollection const* fc) noexcept
403{
404 try
405 {
406 PluginField const* fields = fc->fields;
407
408 PriorBoxParameters params;
409 std::vector<float> minSize;
410 std::vector<float> maxSize;
411 std::vector<float> aspectRatios;
412 for (auto i = 0; i < fc->nbFields; ++i)
413 {
414 char const* attrName = fields[i].name;
415 if (!strcmp(attrName, "minSize"))
416 {
417 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32);
418 int32_t const size = fields[i].length;
419 params.numMinSize = size;
420 if (size > 0)
421 {
422 minSize.resize(size);
423 params.minSize = minSize.data();
424 auto const* minS = static_cast<float const*>(fields[i].data);
425 std::copy_n(minS, size, params.minSize);
426 }
427 else
428 {
429 params.minSize = nullptr;
430 }
431 }
432 else if (!strcmp(attrName, "maxSize"))
433 {
434 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32);
435 int32_t const size = fields[i].length;
436 params.numMaxSize = size;
437 if (size > 0)
438 {
439 maxSize.resize(size);
440 params.maxSize = maxSize.data();
441 auto const* maxS = static_cast<float const*>(fields[i].data);
442 std::copy_n(maxS, size, params.maxSize);
443 }
444 else
445 {
446 params.maxSize = nullptr;
447 }
448 }
449 else if (!strcmp(attrName, "aspectRatios"))
450 {
451 PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32);
452 int32_t const size = fields[i].length;
453 params.numAspectRatios = size;
454 if (size > 0)
455 {
456 aspectRatios.resize(size);
457 params.aspectRatios = aspectRatios.data();
458 auto const* aR = static_cast<float const*>(fields[i].data);
459 std::copy_n(aR, size, params.aspectRatios);

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected