fix(framepack): use text_mask.device instead of hardcoded cuda

get_cu_seqlens creates a cu_seqlens tensor with device="cuda",
which crashes on non-CUDA devices (e.g. Ascend NPU raises
"Torch not compiled with CUDA enabled"). Create it on the same
device as the input text_mask instead, which is device-agnostic.
This commit is contained in:
li-lizhe
2026-09-12 09:08:48 +08:00
parent 684940e015
commit 7d6a98bc62
@@ -74,7 +74,7 @@ def get_cu_seqlens(text_mask, img_len):
text_len = text_mask.sum(dim=1)
max_len = text_mask.shape[1] + img_len
cu_seqlens = torch.zeros([2 * batch_size + 1], dtype=torch.int32, device="cuda")
cu_seqlens = torch.zeros([2 * batch_size + 1], dtype=torch.int32, device=text_mask.device)
for i in range(batch_size):
s = text_len[i] + img_len