Refactor conditional casting, fix upscalers

This commit is contained in:
brkirch
2023-01-27 10:19:43 -05:00
parent c4b9b07db6
commit ada17dbd7c
5 changed files with 25 additions and 10 deletions

View File

@@ -171,7 +171,7 @@ class EmbeddingsWithFixes(torch.nn.Module):
vecs = []
for fixes, tensor in zip(batch_fixes, inputs_embeds):
for offset, embedding in fixes:
emb = embedding.vec.to(devices.dtype_unet) if devices.unet_needs_upcast else embedding.vec
emb = devices.cond_cast_unet(embedding.vec)
emb_len = min(tensor.shape[0] - offset - 1, emb.shape[0])
tensor = torch.cat([tensor[0:offset + 1], emb[0:emb_len], tensor[offset + 1 + emb_len:]])