Skip to content

Commit 3ee5f53

Browse files
committed
[model][NPU]:Z-image model support NPU
1 parent 8f1d10f commit 3ee5f53

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

diffsynth/models/z_image_dit.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from torch.nn import RMSNorm
1010
from ..core.attention import attention_forward
11+
from ..core.device.npu_compatible_device import IS_NPU_AVAILABLE
1112
from ..core.gradient import gradient_checkpoint_forward
1213

1314

@@ -274,7 +275,10 @@ def __call__(self, ids: torch.Tensor):
274275
result = []
275276
for i in range(len(self.axes_dims)):
276277
index = ids[:, i]
277-
result.append(self.freqs_cis[i][index])
278+
if IS_NPU_AVAILABLE:
279+
result.append(self.freqs_cis[i][index])
280+
else:
281+
result.append(torch.index_select(self.freqs_cis[i], 0, index))
278282
return torch.cat(result, dim=-1)
279283

280284

0 commit comments

Comments
 (0)