pytorch
d976df49 - [dynamo] don't use LazyModuleMixin.cls_to_become if it is None (#99943)

Commit
1 year ago
[dynamo] don't use LazyModuleMixin.cls_to_become if it is None (#99943) **TL;DR**: This PR fixes handling for lazy modules where `cls_to_become is None`. In those cases, we should leave the type of the lazy module as the old value. **Details**: Lazy modules are intended to be initialized at execution; some of them are also supposed to switch to a different type after they have been initialized. However, not all are supposed to switch; see this logic from `nn/modules/lazy.py` ```python def _infer_parameters(self, ...): ... if module.cls_to_become is not None: module.__class__ = module.cls_to_become ``` i.e., we should leave the module type as the old value if `module.cls_to_become is None`. This PR updates dynamo's handling to match this behavior. Test `test_lazy_module_no_cls_to_become` added to `test/dynamo/test_module.py`. Differential Revision: [D45253698](https://our.internmc.facebook.com/intern/diff/D45253698) Pull Request resolved: https://github.com/pytorch/pytorch/pull/99943 Approved by: https://github.com/jansel
Author
Committer
Parents
Loading