MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / conv_attn_to_linear

Function conv_attn_to_linear

diffusers/scripts/convert_svd_to_diffusers.py:544–553  ·  view source on GitHub ↗
(checkpoint)

Source from the content-addressed store, hash-verified

542
543
544def conv_attn_to_linear(checkpoint):
545 keys = list(checkpoint.keys())
546 attn_keys = ["to_q.weight", "to_k.weight", "to_v.weight"]
547 for key in keys:
548 if ".".join(key.split(".")[-2:]) in attn_keys:
549 if checkpoint[key].ndim > 2:
550 checkpoint[key] = checkpoint[key][:, :, 0, 0]
551 elif "proj_attn.weight" in key:
552 if checkpoint[key].ndim > 2:
553 checkpoint[key] = checkpoint[key][:, :, 0]
554
555
556def renew_vae_resnet_paths(old_list, n_shave_prefix_segments=0, is_temporal=False):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected