The only reason we overwrite `getattr` here is to gracefully deprecate accessing config attributes directly. See https://github.com/huggingface/diffusers/pull/3129 We need to overwrite __getattr__ here in addition so that we don't trigger `torch.nn.Module`'s __getattr__': htt
(self, name: str)
| 130 | super().__init__() |
| 131 | |
| 132 | def __getattr__(self, name: str) -> Any: |
| 133 | """The only reason we overwrite `getattr` here is to gracefully deprecate accessing |
| 134 | config attributes directly. See https://github.com/huggingface/diffusers/pull/3129 We need to overwrite |
| 135 | __getattr__ here in addition so that we don't trigger `torch.nn.Module`'s __getattr__': |
| 136 | https://pytorch.org/docs/stable/_modules/torch/nn/modules/module.html#Module |
| 137 | """ |
| 138 | |
| 139 | is_in_config = "_internal_dict" in self.__dict__ and hasattr(self.__dict__["_internal_dict"], name) |
| 140 | is_attribute = name in self.__dict__ |
| 141 | |
| 142 | if is_in_config and not is_attribute: |
| 143 | deprecation_message = f"Accessing config attribute `{name}` directly via '{type(self).__name__}' object attribute is deprecated. Please access '{name}' over '{type(self).__name__}'s config object instead, e.g. 'unet.config.{name}'." |
| 144 | deprecate("direct config name access", "1.0.0", deprecation_message, standard_warn=False, stacklevel=3) |
| 145 | return self._internal_dict[name] |
| 146 | |
| 147 | # call PyTorch's https://pytorch.org/docs/stable/_modules/torch/nn/modules/module.html#Module |
| 148 | return super().__getattr__(name) |
| 149 | |
| 150 | @property |
| 151 | def is_gradient_checkpointing(self) -> bool: |
nothing calls this directly
no test coverage detected