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

Method createPlugin

plugin/skipLayerNormPlugin/skipLayerNormPlugin.cpp:481–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

479}
480
481IPluginV2* SkipLayerNormPluginDynamicCreator::createPlugin(char const* name, PluginFieldCollection const* fc) noexcept
482{
483 try
484 {
485 BERT_DEBUG_MSG("SkipLayerNormPluginDynamicCreator createPlugin");
486
487 int32_t ld = 0;
488 Weights beta{DataType::kFLOAT, nullptr, 0};
489 Weights gamma{DataType::kFLOAT, nullptr, 0};
490 Weights bias{DataType::kFLOAT, nullptr, 0};
491 int32_t typeId = -1;
492
493 PLUGIN_VALIDATE(fc != nullptr);
494
495 plugin::validateRequiredAttributesExist({"type_id", "beta", "ld", "gamma"}, fc);
496
497 for (int32_t i = 0; i < fc->nbFields; i++)
498 {
499 std::string field_name(fc->fields[i].name);
500 if (field_name.compare("ld") == 0)
501 {
502 ld = *static_cast<int32_t const*>(fc->fields[i].data);
503 BERT_DEBUG_VALUE("Building ld: ", ld);
504 }
505
506 if (field_name.compare("type_id") == 0)
507 {
508 typeId = *static_cast<int32_t const*>(fc->fields[i].data);
509 BERT_DEBUG_VALUE("Building typeId: ", typeId);
510 }
511
512 if (field_name.compare("beta") == 0)
513 {
514 BERT_DEBUG_MSG("Building beta...");
515 beta.values = fc->fields[i].data;
516 beta.count = fc->fields[i].length;
517 beta.type = fieldTypeToDataType(fc->fields[i].type);
518 }
519
520 if (field_name.compare("gamma") == 0)
521 {
522 BERT_DEBUG_MSG("Building gamma...");
523 gamma.values = fc->fields[i].data;
524 gamma.count = fc->fields[i].length;
525 gamma.type = fieldTypeToDataType(fc->fields[i].type);
526 }
527
528 if (field_name.compare("bias") == 0)
529 {
530 BERT_DEBUG_MSG("Building bias...");
531 bias.values = fc->fields[i].data;
532 bias.count = fc->fields[i].length;
533 bias.type = fieldTypeToDataType(fc->fields[i].type);
534 }
535 }
536 BERT_DEBUG_VALUE("Type ", typeId);
537
538 PLUGIN_VALIDATE(

Callers

nothing calls this directly

Calls 4

fieldTypeToDataTypeFunction · 0.85
caughtErrorFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected