yannvgn / laserembeddings

LASER multilingual sentence embeddings as a pip package
BSD 3-Clause "New" or "Revised" License
224 stars 29 forks source link

fix pytorch 1.4 warning (encoder) #19

Closed yannvgn closed 4 years ago

yannvgn commented 4 years ago

When using laserembeddings with PyTorch >= 1.4.0, you might sometimes get a warning like this:

The number of elements in the out tensor of shape [...] is [...] which does not match the computed number of elements [...]. Note that this may occur as a result of rounding error. The out tensor will be resized to a tensor of shape ([...]).

Related to: https://github.com/pytorch/pytorch/issues/28347, https://github.com/pytorch/pytorch/pull/29195.

This PR fixes a util function in the encoder that would sometimes cause this warning to appear.