mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-22 05:08:08 +08:00
pick up preivously set attributes (#905)
This commit is contained in:
@@ -138,6 +138,11 @@ class Module(dict):
|
||||
|
||||
def __setattr__(self, key: str, val: Any):
|
||||
if isinstance(val, (mx.array, dict, list, tuple)):
|
||||
# If attribute was previously set but not in the
|
||||
# dictionary, delete it so we pick it up in future
|
||||
# calls to __getattr__
|
||||
if hasattr(self, key) and key not in self:
|
||||
delattr(self, key)
|
||||
self[key] = val
|
||||
else:
|
||||
super(Module, self).__setattr__(key, val)
|
||||
|
Reference in New Issue
Block a user