| 311 | } |
| 312 | |
| 313 | IPluginV2Ext* NormalizePluginCreator::createPlugin(char const* name, PluginFieldCollection const* fc) noexcept |
| 314 | { |
| 315 | try |
| 316 | { |
| 317 | std::vector<float> weightValues; |
| 318 | PluginField const* fields = fc->fields; |
| 319 | for (int32_t i = 0; i < fc->nbFields; ++i) |
| 320 | { |
| 321 | char const* attrName = fields[i].name; |
| 322 | if (!strcmp(attrName, "nbWeights")) |
| 323 | { |
| 324 | PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32); |
| 325 | mNbWeights = *(static_cast<int32_t const*>(fields[i].data)); |
| 326 | } |
| 327 | else if (!strcmp(attrName, "acrossSpatial")) |
| 328 | { |
| 329 | PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32); |
| 330 | mAcrossSpatial = *(static_cast<bool const*>(fields[i].data)); |
| 331 | } |
| 332 | else if (!strcmp(attrName, "channelShared")) |
| 333 | { |
| 334 | PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kINT32); |
| 335 | mChannelShared = *(static_cast<bool const*>(fields[i].data)); |
| 336 | } |
| 337 | else if (!strcmp(attrName, "eps")) |
| 338 | { |
| 339 | PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32); |
| 340 | mEps = *(static_cast<float const*>(fields[i].data)); |
| 341 | } |
| 342 | else if (!strcmp(attrName, "weights")) |
| 343 | { |
| 344 | PLUGIN_VALIDATE(fields[i].type == PluginFieldType::kFLOAT32); |
| 345 | int32_t size = fields[i].length; |
| 346 | weightValues.reserve(size); |
| 347 | auto const* w = static_cast<float const*>(fields[i].data); |
| 348 | for (int32_t j = 0; j < size; j++) |
| 349 | { |
| 350 | weightValues.push_back(*w); |
| 351 | w++; |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | Weights weights{DataType::kFLOAT, weightValues.data(), (int64_t) weightValues.size()}; |
| 356 | |
| 357 | Normalize* obj = new Normalize(&weights, mNbWeights, mAcrossSpatial, mChannelShared, mEps); |
| 358 | obj->setPluginNamespace(mNamespace.c_str()); |
| 359 | return obj; |
| 360 | } |
| 361 | catch (std::exception const& e) |
| 362 | { |
| 363 | caughtError(e); |
| 364 | } |
| 365 | return nullptr; |
| 366 | } |
| 367 | |
| 368 | IPluginV2Ext* NormalizePluginCreator::deserializePlugin( |
| 369 | char const* name, void const* serialData, size_t serialLength) noexcept |
nothing calls this directly
no test coverage detected