pytorch
4dc57983 - Allow fx.Graph.owning_module to be used as attribute. (#86822)

Comment changes are shownComment changes are hidden
Commit
2 years ago
Allow fx.Graph.owning_module to be used as attribute. (#86822) Summary: The current behavior of owning_module setter is difficult to understand: it changes the owning_module to None if owners is not 0 but increments the owners count. If the owning_module is None, the owners count should be 0 as none of them is accessible. On the other hand, if the owners count increases, the owning_module should be a collection (e.g. a list). This diff changes owning_module to be a normal attribute. The semantic is that graph can have **at most one** owning module and can be assigned to new module. The alternative is to use a list to represent the owning_modules of a graph but it breaks backward compatibility and the exact use cases of having multiple owning_modules are not clear. Test Plan: Test with CI. Differential Revision: D40200624 Pull Request resolved: https://github.com/pytorch/pytorch/pull/86822 Approved by: https://github.com/tugsbayasgalan
Author
Committer
Parents
  • torch/fx
    • experimental
      • File
        const_fold.py
    • File
      graph.py