| 509 | } |
| 510 | |
| 511 | nvinfer1::ILayer* netAddMaxpool(int layerIdx, std::map<std::string, std::string>& block, |
| 512 | nvinfer1::ITensor* input, nvinfer1::INetworkDefinition* network) |
| 513 | { |
| 514 | assert(block.at("type") == "maxpool"); |
| 515 | assert(block.find("size") != block.end()); |
| 516 | assert(block.find("stride") != block.end()); |
| 517 | |
| 518 | int size = std::stoi(block.at("size")); |
| 519 | int stride = std::stoi(block.at("stride")); |
| 520 | |
| 521 | nvinfer1::IPoolingLayer* pool |
| 522 | = network->addPoolingNd(*input, nvinfer1::PoolingType::kMAX, nvinfer1::DimsHW{size, size}); |
| 523 | assert(pool); |
| 524 | std::string maxpoolLayerName = "maxpool_" + std::to_string(layerIdx); |
| 525 | int pad = (size - 1) / 2; |
| 526 | pool->setPaddingNd(nvinfer1::DimsHW{pad,pad}); |
| 527 | pool->setStrideNd(nvinfer1::DimsHW{stride, stride}); |
| 528 | pool->setName(maxpoolLayerName.c_str()); |
| 529 | |
| 530 | return pool; |
| 531 | } |
| 532 | |
| 533 | nvinfer1::ILayer* netAddConvLinear(int layerIdx, std::map<std::string, std::string>& block, |
| 534 | std::vector<float>& weights, |