aiqm / torchani

Accurate Neural Network Potential on PyTorch
https://aiqm.github.io/torchani/
MIT License
449 stars 125 forks source link

SpeciesConverter returns species on CPU #461

Closed RMeli closed 4 years ago

RMeli commented 4 years ago

torchani.SpeciesConverter always returns species on the CPU, even if the inputs of forward are on the GPU.

import torch
import torchani

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

print("device:", device)

SC = torchani.SpeciesConverter("H")

atomicnums = torch.tensor([[1, 1]], device=device)
coordinates = torch.tensor([[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]]], device=device)

print(atomicnums.device, coordinates.device)

sc = SC((atomicnums, coordinates))

print(sc.species.device, sc.coordinates.device)
device: cuda
cuda:0 cuda:0
cpu cuda:0

TorchANI: 2.0 Pythorch: 1.5 Python: 3.7

zasdfgbnm commented 4 years ago

@RMeli Thanks for reporting and fixing!