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

Function swap_scale_shift

diffusers/src/diffusers/loaders/single_file_utils.py:1667–1670  ·  view source on GitHub ↗
(weight, dim)

Source from the content-addressed store, hash-verified

1665# in SD3 original implementation of AdaLayerNormContinuous, it split linear projection output into shift, scale;
1666# while in diffusers it split into scale, shift. Here we swap the linear projection weights in order to be able to use diffusers implementation
1667def swap_scale_shift(weight, dim):
1668 shift, scale = weight.chunk(2, dim=0)
1669 new_weight = torch.cat([scale, shift], dim=0)
1670 return new_weight
1671
1672
1673def convert_sd3_transformer_checkpoint_to_diffusers(checkpoint, **kwargs):

Calls

no outgoing calls

Tested by

no test coverage detected