CTranslate2
CTranslate2 copied to clipboard
Incorrect device index in `StorageView`
import torch
import ctranslate2
x0 = torch.ones((2, 4), dtype=torch.int32, device="cuda:0")
y0 = ctranslate2.StorageView.from_array(x0)
print(f"Original tensor is on {x0.device} and StorageView is on {y0.device}:{y0.device_index}")
x1 = torch.ones((2, 4), dtype=torch.int32, device="cuda:1")
y1 = ctranslate2.StorageView.from_array(x1)
print(f"Original tensor is on {x1.device} and StorageView is on {y1.device}:{y1.device_index}")
The output I get is
Original tensor is on cuda:0 and StorageView is on cuda:0
Original tensor is on cuda:1 and StorageView is on cuda:0
The actual data is still on cuda:0
for y0
and on cuda:1
for y1
.