MCPcopy Create free account
hub / github.com/ml-explore/mlx / test_module_attributes

Method test_module_attributes

python/tests/test_nn.py:57–74  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

55 m.apply_to_modules(assert_training)
56
57 def test_module_attributes(self):
58 class Model(nn.Module):
59 def __init__(self):
60 super().__init__()
61 self.val = None
62 self.initialize()
63
64 def initialize(self):
65 self.val = mx.array(1.0)
66
67 model = Model()
68 self.assertTrue(mx.array_equal(model.val, mx.array(1.0)))
69
70 model.val = None
71 self.assertEqual(model.val, None)
72
73 model.val = mx.array([3])
74 self.assertEqual(model.val.item(), 3)
75
76 def test_model_with_dict(self):
77 class DictModule(nn.Module):

Callers

nothing calls this directly

Calls 3

itemMethod · 0.80
ModelClass · 0.70
arrayMethod · 0.60

Tested by

no test coverage detected