| 58 | |
| 59 | |
| 60 | class ResNet(M.Module): |
| 61 | def __init__(self, block, num_blocks, num_classes=10): |
| 62 | super(ResNet, self).__init__() |
| 63 | self.in_planes = 16 |
| 64 | |
| 65 | self.conv1 = M.Conv2d(3, 16, kernel_size=3, stride=1, padding=1, bias=False) |
| 66 | self.bn1 = M.BatchNorm2d(16) |
| 67 | self.layer1 = self._make_layer(block, 16, num_blocks[0], stride=1) |
| 68 | self.layer2 = self._make_layer(block, 32, num_blocks[1], stride=2) |
| 69 | self.layer3 = self._make_layer(block, 64, num_blocks[2], stride=2) |
| 70 | self.linear = M.Linear(64, num_classes) |
| 71 | |
| 72 | self.apply(_weights_init) |
| 73 | |
| 74 | def _make_layer(self, block, planes, num_blocks, stride): |
| 75 | strides = [stride] + [1] * (num_blocks - 1) |
| 76 | layers = [] |
| 77 | for stride in strides: |
| 78 | layers.append(block(self.in_planes, planes, stride)) |
| 79 | self.in_planes = planes * block.expansion |
| 80 | |
| 81 | return M.Sequential(*layers) |
| 82 | |
| 83 | def forward(self, x): |
| 84 | out = F.relu(self.bn1(self.conv1(x))) |
| 85 | out = self.layer1(out) |
| 86 | out = self.layer2(out) |
| 87 | out = self.layer3(out) |
| 88 | out = out.mean(3).mean(2) |
| 89 | out = self.linear(out) |
| 90 | return out |
| 91 | |
| 92 | |
| 93 | def run_dtr_drop_copy_dev_tensor(): |
no outgoing calls