MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / MyModule

Class MyModule

imperative/python/test/unit/xla/test_xla_trace.py:93–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91@pytest.mark.skipif(not is_cuda_available(), reason="only support cuda now")
92def 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)

Callers 2

testerFunction · 0.70

Calls

no outgoing calls

Tested by 2

testerFunction · 0.56