| 530 | } |
| 531 | |
| 532 | IPluginV2* EmbLayerNormPluginDynamicCreator::createPlugin(char const* name, PluginFieldCollection const* fc) noexcept |
| 533 | { |
| 534 | try |
| 535 | { |
| 536 | BERT_DEBUG_MSG("EmbLayerNormPluginDynamic createPlugin."); |
| 537 | |
| 538 | bool output_fp16 = false; |
| 539 | bool useFullMask = false; |
| 540 | Weights beta{}; // required attribute - validateRequiredAttributesExist() will verify existence |
| 541 | Weights gamma{}; // required attribute - validateRequiredAttributesExist() will verify existence |
| 542 | Weights word_emb{}; // required attribute - validateRequiredAttributesExist() will verify existence |
| 543 | Weights pos_emb{}; // required attribute - validateRequiredAttributesExist() will verify existence |
| 544 | Weights tok_emb{}; // required attribute - validateRequiredAttributesExist() will verify existence |
| 545 | int32_t mhaTypeId = 0; |
| 546 | std::set<std::string> const requiredAttributes{ |
| 547 | "bert_embeddings_layernorm_beta", |
| 548 | "bert_embeddings_layernorm_gamma", |
| 549 | "bert_embeddings_word_embeddings", |
| 550 | "bert_embeddings_token_type_embeddings", |
| 551 | "bert_embeddings_position_embeddings", |
| 552 | }; |
| 553 | plugin::validateRequiredAttributesExist(requiredAttributes, fc); |
| 554 | |
| 555 | for (int32_t i = 0; i < fc->nbFields; i++) |
| 556 | { |
| 557 | std::string field_name(fc->fields[i].name); |
| 558 | if (field_name.compare("bert_embeddings_layernorm_beta") == 0) |
| 559 | { |
| 560 | BERT_DEBUG_MSG("Building bert_embeddings_layernorm_beta..."); |
| 561 | beta.values = fc->fields[i].data; |
| 562 | beta.count = fc->fields[i].length; |
| 563 | beta.type = fieldTypeToDataType(fc->fields[i].type); |
| 564 | } |
| 565 | |
| 566 | if (field_name.compare("bert_embeddings_layernorm_gamma") == 0) |
| 567 | { |
| 568 | BERT_DEBUG_MSG("Building bert_embeddings_layernorm_gamma..."); |
| 569 | gamma.values = fc->fields[i].data; |
| 570 | gamma.count = fc->fields[i].length; |
| 571 | gamma.type = fieldTypeToDataType(fc->fields[i].type); |
| 572 | } |
| 573 | |
| 574 | if (field_name.compare("bert_embeddings_word_embeddings") == 0) |
| 575 | { |
| 576 | BERT_DEBUG_MSG("Building bert_embeddings_word_embeddings..."); |
| 577 | word_emb.values = fc->fields[i].data; |
| 578 | word_emb.count = fc->fields[i].length; |
| 579 | word_emb.type = fieldTypeToDataType(fc->fields[i].type); |
| 580 | } |
| 581 | |
| 582 | if (field_name.compare("bert_embeddings_token_type_embeddings") == 0) |
| 583 | { |
| 584 | BERT_DEBUG_MSG("Building bert_embeddings_token_type_embeddings..."); |
| 585 | tok_emb.values = fc->fields[i].data; |
| 586 | tok_emb.count = fc->fields[i].length; |
| 587 | tok_emb.type = fieldTypeToDataType(fc->fields[i].type); |
| 588 | } |
| 589 |
nothing calls this directly
no test coverage detected