(module, state_dict, *args, **kwargs)
| 30 | # we add a hook to state_dict() and load_state_dict() so that the |
| 31 | # naming fits with `unet.attn_processors` |
| 32 | def map_to(module, state_dict, *args, **kwargs): |
| 33 | new_state_dict = {} |
| 34 | for key, value in state_dict.items(): |
| 35 | num = int(key.split(".")[1]) # 0 is always "layers" |
| 36 | new_key = key.replace(f"layers.{num}", module.mapping[num]) |
| 37 | new_state_dict[new_key] = value |
| 38 | |
| 39 | return new_state_dict |
| 40 | |
| 41 | def remap_key(key, state_dict): |
| 42 | for k in self.split_keys: |
nothing calls this directly
no outgoing calls
no test coverage detected