Updates paths inside attentions to the new naming scheme (local renaming)
(old_list, n_shave_prefix_segments=0)
| 637 | |
| 638 | |
| 639 | def renew_vae_attention_paths(old_list, n_shave_prefix_segments=0): |
| 640 | """ |
| 641 | Updates paths inside attentions to the new naming scheme (local renaming) |
| 642 | """ |
| 643 | mapping = [] |
| 644 | for old_item in old_list: |
| 645 | new_item = old_item |
| 646 | |
| 647 | new_item = new_item.replace("norm.weight", "group_norm.weight") |
| 648 | new_item = new_item.replace("norm.bias", "group_norm.bias") |
| 649 | |
| 650 | new_item = new_item.replace("q.weight", "to_q.weight") |
| 651 | new_item = new_item.replace("q.bias", "to_q.bias") |
| 652 | |
| 653 | new_item = new_item.replace("k.weight", "to_k.weight") |
| 654 | new_item = new_item.replace("k.bias", "to_k.bias") |
| 655 | |
| 656 | new_item = new_item.replace("v.weight", "to_v.weight") |
| 657 | new_item = new_item.replace("v.bias", "to_v.bias") |
| 658 | |
| 659 | new_item = new_item.replace("proj_out.weight", "to_out.0.weight") |
| 660 | new_item = new_item.replace("proj_out.bias", "to_out.0.bias") |
| 661 | |
| 662 | new_item = shave_segments(new_item, n_shave_prefix_segments=n_shave_prefix_segments) |
| 663 | |
| 664 | mapping.append({"old": old_item, "new": new_item}) |
| 665 | |
| 666 | return mapping |
| 667 | |
| 668 | |
| 669 | def conv_attn_to_linear(checkpoint): |
no test coverage detected