r""" Set the attention processor to use. Args: processor (`AttnProcessor`): The attention processor to use.
(self, processor: "AttnProcessor")
| 533 | self.set_processor(processor) |
| 534 | |
| 535 | def set_processor(self, processor: "AttnProcessor") -> None: |
| 536 | r""" |
| 537 | Set the attention processor to use. |
| 538 | |
| 539 | Args: |
| 540 | processor (`AttnProcessor`): |
| 541 | The attention processor to use. |
| 542 | """ |
| 543 | # if current processor is in `self._modules` and if passed `processor` is not, we need to |
| 544 | # pop `processor` from `self._modules` |
| 545 | if ( |
| 546 | hasattr(self, "processor") |
| 547 | and isinstance(self.processor, torch.nn.Module) |
| 548 | and not isinstance(processor, torch.nn.Module) |
| 549 | ): |
| 550 | logger.info(f"You are removing possibly trained weights of {self.processor} with {processor}") |
| 551 | self._modules.pop("processor") |
| 552 | |
| 553 | self.processor = processor |
| 554 | |
| 555 | def get_processor(self, return_deprecated_lora: bool = False) -> "AttentionProcessor": |
| 556 | r""" |