| 9 | |
| 10 | |
| 11 | class Simple(Module): |
| 12 | def __init__(self): |
| 13 | super().__init__() |
| 14 | self.a = Parameter([1.0], dtype=np.float32) |
| 15 | self.b = Parameter([1.0], dtype=np.float32) |
| 16 | |
| 17 | def forward(self, x): |
| 18 | x = x * self.a |
| 19 | x = x.detach() * self.b |
| 20 | return x |
| 21 | |
| 22 | |
| 23 | def test_detach(): |