mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Before, having arbitrary depth nested configs like ``` class Foo: foo: List[int] = [1, 2, 3] class Bar: bar: str = "1" class Baz: baz: int = 1 ``` would cause problems beyond the first layer. For example, if we tried ``` from torch._inductor import config as inductor_config print(inductor_config.Foo) print(repr(inductor_config.Foo.foo)) print(inductor_config.Foo.Bar) print(repr(inductor_config.Foo.Bar.bar)) print(inductor_config.Foo.Bar.Baz) print(repr(inductor_config.Foo.Bar.Baz.baz)) ``` we would get some output like ``` <torch.utils._config_module.SubConfigProxy object at 0x7fac65de00a0> [1, 2, 3] ... AttributeError: torch._inductor.config.Foo.Bar does not exist ``` Obviously, this is not what we want. With these changes, we get the right values ``` <torch.utils._config_module.SubConfigProxy object at 0x7f840d05bf40> [1, 2, 3] <torch.utils._config_module.SubConfigProxy object at 0x7f840cedc940> '1' <torch.utils._config_module.SubConfigProxy object at 0x7f840cedc100> 1 ``` Fixes #ISSUE_NUMBER Pull Request resolved: https://github.com/pytorch/pytorch/pull/133418 Approved by: https://github.com/oulgen
Note [TH abstraction violation] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TH/THC provide some hpp headers, which are proper C++ headers rather than C headers. These headers serve double duty as *internal implementation detail* headers, whose contents should largely not be used by external clients. Ideally, we would not install these headers at all; instead, you should use public functions (in headers like `THTensor.h`, NOT `THTensor.hpp`) to manipulate these structs. However, there are a few places in torch/csrc where we violate this abstraction. They are marked with a pointer to this note. Each of those sites will have to be refactored when we refactor the guts of THTensor and related structures.