(adapter_names, weights)
| 125 | ) |
| 126 | |
| 127 | def process_weights(adapter_names, weights): |
| 128 | # Expand weights into a list, one entry per adapter |
| 129 | # e.g. for 2 adapters: 7 -> [7,7] ; [3, None] -> [3, None] |
| 130 | if not isinstance(weights, list): |
| 131 | weights = [weights] * len(adapter_names) |
| 132 | |
| 133 | if len(adapter_names) != len(weights): |
| 134 | raise ValueError( |
| 135 | f"Length of adapter names {len(adapter_names)} is not equal to the length of the weights {len(weights)}" |
| 136 | ) |
| 137 | |
| 138 | # Set None values to default of 1.0 |
| 139 | # e.g. [7,7] -> [7,7] ; [3, None] -> [3,1] |
| 140 | weights = [w if w is not None else 1.0 for w in weights] |
| 141 | |
| 142 | return weights |
| 143 | |
| 144 | adapter_names = [adapter_names] if isinstance(adapter_names, str) else adapter_names |
| 145 | text_encoder_weights = process_weights(adapter_names, text_encoder_weights) |
no outgoing calls
no test coverage detected