(x)
| 68 | def forward(self, x): |
| 69 | """Forward function.""" |
| 70 | def _inner_forward(x): |
| 71 | identity = x |
| 72 | |
| 73 | out = self.conv1(x) |
| 74 | out = self.norm1(out) |
| 75 | out = self.relu(out) |
| 76 | |
| 77 | out = self.conv2(out) |
| 78 | out = self.norm2(out) |
| 79 | |
| 80 | if self.downsample is not None: |
| 81 | identity = self.downsample(x) |
| 82 | |
| 83 | out += identity |
| 84 | |
| 85 | return out |
| 86 | |
| 87 | if self.with_cp and x.requires_grad: |
| 88 | out = cp.checkpoint(_inner_forward, x) |