(state_dict)
| 218 | |
| 219 | |
| 220 | def rename_orig_weights(state_dict): |
| 221 | new_state_dict = {} |
| 222 | for k, v in state_dict.items(): |
| 223 | if k.endswith("kernel"): |
| 224 | # up- and downsample layers, don't have trainable weights |
| 225 | continue |
| 226 | |
| 227 | new_k = rename(k) |
| 228 | |
| 229 | # check if we need to transform from Conv => Linear for attention |
| 230 | if isinstance(new_k, list): |
| 231 | new_state_dict = transform_conv_attns(new_state_dict, new_k, v) |
| 232 | else: |
| 233 | new_state_dict[new_k] = v |
| 234 | |
| 235 | return new_state_dict |
| 236 | |
| 237 | |
| 238 | def transform_conv_attns(new_state_dict, new_k, v): |
no test coverage detected