| 91 | @pytest.mark.skipif(not is_cuda_available(), reason="only support cuda now") |
| 92 | def test_xla_trace_with_property(): |
| 93 | class MyModule(M.Module): |
| 94 | def __init__(self, in_channels, out_channels): |
| 95 | super().__init__() |
| 96 | self.weight = Parameter(np.random.randn(in_channels, out_channels)) |
| 97 | |
| 98 | @property |
| 99 | def _weight(self): |
| 100 | return self.weight + 1 |
| 101 | |
| 102 | def forward(self, x): |
| 103 | self.weight[...] = self._weight |
| 104 | return F.matmul(x, self._weight) |
| 105 | |
| 106 | n, ic, oc = 2, 3, 4 |
| 107 | mod = MyModule(ic, oc) |
no outgoing calls