Torch.mm underflow error

When using torch.mm function I get an underflow error such that I get an output matrix of NaNs that is passed to subsequent layers of my model. How can I avoid this underflow error? Is it possible to calculate a matrix multiplication in log-scale, for example?