From 03613ead1014836619ae4a446d654dc800b4263d Mon Sep 17 00:00:00 2001 From: drhead <1313496+drhead@users.noreply.github.com> Date: Sat, 15 Jun 2024 03:10:37 -0400 Subject: [PATCH] change repeat to batch size to use a view --- comfy/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/comfy/utils.py b/comfy/utils.py index 884404cce..1c772677d 100644 --- a/comfy/utils.py +++ b/comfy/utils.py @@ -253,7 +253,9 @@ def repeat_to_batch_size(tensor, batch_size, dim=0): if tensor.shape[dim] > batch_size: return tensor.narrow(dim, 0, batch_size) elif tensor.shape[dim] < batch_size: - return tensor.repeat(dim * [1] + [math.ceil(batch_size / tensor.shape[dim])] + [1] * (len(tensor.shape) - 1 - dim)).narrow(dim, 0, batch_size) + expand_shape = list(tensor.shape) + expand_shape[dim] = batch_size + return tensor.expand(expand_shape) return tensor def resize_to_batch_size(tensor, batch_size):