| 327 | } |
| 328 | |
| 329 | IPluginV2* GeluPluginDynamicCreator::createPlugin(char const* name, PluginFieldCollection const* fc) noexcept |
| 330 | { |
| 331 | try |
| 332 | { |
| 333 | gLogVerbose << "GeluPluginDynamicCreator createPlugin\n"; |
| 334 | PLUGIN_VALIDATE(fc != nullptr); |
| 335 | |
| 336 | Weights bias{DataType::kFLOAT, nullptr, 0}; |
| 337 | int32_t typeId = -1; |
| 338 | plugin::validateRequiredAttributesExist({"type_id"}, fc); |
| 339 | |
| 340 | for (int32_t i = 0; i < fc->nbFields; i++) |
| 341 | { |
| 342 | PLUGIN_VALIDATE(fc->fields[i].name != nullptr); |
| 343 | std::string fieldName(fc->fields[i].name); |
| 344 | |
| 345 | if (fieldName.compare("type_id") == 0) |
| 346 | { |
| 347 | typeId = *static_cast<int32_t const*>(fc->fields[i].data); |
| 348 | } |
| 349 | if (fieldName.compare("bias") == 0) |
| 350 | { |
| 351 | bias.values = fc->fields[i].data; |
| 352 | bias.count = fc->fields[i].length; |
| 353 | bias.type = fieldTypeToDataType(fc->fields[i].type); |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | if (typeId < 0 || typeId > 3) |
| 358 | { |
| 359 | gLogError << "GeluPluginDynamicCreator: invalid typeId " << typeId << std::endl; |
| 360 | return nullptr; |
| 361 | } |
| 362 | |
| 363 | return new GeluPluginDynamic(name, static_cast<DataType>(typeId), bias); |
| 364 | } |
| 365 | catch (std::exception const& e) |
| 366 | { |
| 367 | caughtError(e); |
| 368 | } |
| 369 | return nullptr; |
| 370 | } |
| 371 | |
| 372 | IPluginV2* GeluPluginDynamicCreator::deserializePlugin( |
| 373 | char const* name, void const* serialData, size_t serialLength) noexcept |
nothing calls this directly
no test coverage detected