pytorch / text

Models, data loaders and abstractions for language processing, powered by PyTorch
https://pytorch.org/text
BSD 3-Clause "New" or "Revised" License
3.49k stars 815 forks source link

Loading vectors into a GPU #2145

Closed saeeddhqan closed 1 year ago

saeeddhqan commented 1 year ago

🚀 Feature

Is there any way for loading vectors based on device with torchtext.vocab.Vectors class?

joecummings commented 1 year ago

This can be accomplished with our prototype Vectors class, which will eventually replace the current implementation.

See here: https://github.com/pytorch/text/blob/79100a64104df26df4d11a87344d6edd8be718ad/torchtext/prototype/vectors.py#L202

saeeddhqan commented 1 year ago

So, we don't need to change the current implementation to do so, right?

joecummings commented 1 year ago

Nope! You can just do:

vectors = Vectors()
vectors.to(device="cuda")
saeeddhqan commented 1 year ago

thanks!