mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-17 17:43:30 +00:00
Compare commits
4 Commits
106c6c45bb
...
a58ef65212
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a58ef65212 | ||
![]() |
d175cbd315 | ||
![]() |
8e5f33cc9c | ||
![]() |
c7b8e7250d |
@ -1,6 +1,7 @@
|
|||||||
import torch
|
import torch
|
||||||
import math
|
import math
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
|
from comfy.model_management import device_should_use_non_blocking
|
||||||
|
|
||||||
|
|
||||||
class CONDRegular:
|
class CONDRegular:
|
||||||
@ -10,8 +11,17 @@ class CONDRegular:
|
|||||||
def _copy_with(self, cond):
|
def _copy_with(self, cond):
|
||||||
return self.__class__(cond)
|
return self.__class__(cond)
|
||||||
|
|
||||||
|
def _pin_memory(self, cond):
|
||||||
|
if cond.device == torch.device('cpu'):
|
||||||
|
return cond.pin_memory()
|
||||||
|
else:
|
||||||
|
return cond
|
||||||
|
|
||||||
def process_cond(self, batch_size, device, **kwargs):
|
def process_cond(self, batch_size, device, **kwargs):
|
||||||
return self._copy_with(comfy.utils.repeat_to_batch_size(self.cond, batch_size).to(device))
|
if device_should_use_non_blocking(device):
|
||||||
|
return self._copy_with(comfy.utils.repeat_to_batch_size(self._pin_memory(self.cond), batch_size).to(device, non_blocking=True))
|
||||||
|
else:
|
||||||
|
return self._copy_with(comfy.utils.repeat_to_batch_size(self.cond, batch_size).to(device))
|
||||||
|
|
||||||
def can_concat(self, other):
|
def can_concat(self, other):
|
||||||
if self.cond.shape != other.cond.shape:
|
if self.cond.shape != other.cond.shape:
|
||||||
|
Loading…
Reference in New Issue
Block a user