| 126 | } |
| 127 | |
| 128 | torch::nn::Sequential ResNetImpl::_make_layer(int64_t planes, int64_t blocks, int64_t stride) { |
| 129 | |
| 130 | torch::nn::Sequential downsample; |
| 131 | if (stride != 1 || inplanes != planes * expansion) { |
| 132 | downsample = torch::nn::Sequential( |
| 133 | torch::nn::Conv2d(conv_options(inplanes, planes * expansion, 1, stride, 0, 1, false)), |
| 134 | torch::nn::BatchNorm2d(planes * expansion) |
| 135 | ); |
| 136 | } |
| 137 | torch::nn::Sequential layers; |
| 138 | layers->push_back(Block(inplanes, planes, stride, downsample, groups, base_width, is_basic)); |
| 139 | inplanes = planes * expansion; |
| 140 | for (int64_t i = 1; i < blocks; i++) { |
| 141 | layers->push_back(Block(inplanes, planes, 1, torch::nn::Sequential(), groups, base_width,is_basic)); |
| 142 | } |
| 143 | |
| 144 | return layers; |
| 145 | } |
| 146 | |
| 147 | void ResNetImpl::make_dilated(std::vector<int> stage_list, std::vector<int> dilation_list) { |
| 148 | if (stage_list.size() != dilation_list.size()) { |
nothing calls this directly
no test coverage detected