| 47 | } |
| 48 | |
| 49 | std::vector<nvinfer1::PluginField> CaffeParser::parseNormalizeParam(const trtcaffe::LayerParameter& msg, CaffeWeightFactory& weightFactory, BlobNameToTensor& tensors) |
| 50 | { |
| 51 | std::vector<nvinfer1::PluginField> f; |
| 52 | const trtcaffe::NormalizeParameter& p = msg.norm_param(); |
| 53 | |
| 54 | int* acrossSpatial = allocMemory<int32_t>(); |
| 55 | *acrossSpatial = p.across_spatial() ? 1 : 0; |
| 56 | f.emplace_back("acrossSpatial", acrossSpatial, PluginFieldType::kINT32, 1); |
| 57 | |
| 58 | int* channelShared = allocMemory<int32_t>(); |
| 59 | *channelShared = p.channel_shared() ? 1 : 0; |
| 60 | f.emplace_back("channelShared", channelShared, PluginFieldType::kINT32, 1); |
| 61 | |
| 62 | auto* eps = allocMemory<float>(); |
| 63 | *eps = p.eps(); |
| 64 | f.emplace_back("eps", eps, PluginFieldType::kFLOAT32, 1); |
| 65 | |
| 66 | std::vector<Weights> w; |
| 67 | // If .caffemodel is not provided, need to randomize the weight |
| 68 | if (!weightFactory.isInitialized()) |
| 69 | { |
| 70 | int C = parserutils::getC(tensors[msg.bottom(0)]->getDimensions()); |
| 71 | w.emplace_back(weightFactory.allocateWeights(C, std::normal_distribution<float>(0.0F, 1.0F))); |
| 72 | } |
| 73 | else |
| 74 | { |
| 75 | // Use the provided weight from .caffemodel |
| 76 | w = weightFactory.getAllWeights(msg.name()); |
| 77 | } |
| 78 | |
| 79 | for (auto weight : w) |
| 80 | { |
| 81 | f.emplace_back("weights", weight.values, PluginFieldType::kFLOAT32, weight.count); |
| 82 | } |
| 83 | |
| 84 | int* nbWeights = allocMemory<int32_t>(); |
| 85 | *nbWeights = w.size(); |
| 86 | f.emplace_back("nbWeights", nbWeights, PluginFieldType::kINT32, 1); |
| 87 | |
| 88 | return f; |
| 89 | } |
| 90 | |
| 91 | std::vector<nvinfer1::PluginField> CaffeParser::parsePriorBoxParam(const trtcaffe::LayerParameter& msg, CaffeWeightFactory& /*weightFactory*/, BlobNameToTensor& /*tensors*/) |
| 92 | { |
nothing calls this directly
no test coverage detected