I know this conversation is old, but maybe it still helps someone: Just like in TensorFlow, you can use lgamma, the log of the gamma function, to calculate the factorial, as n! == gamma(n+1) == exp(lgamma(n+1)) for integers n.
Compare
from math import factorial
print([factorial(n) for n in range(5)])
>>> [1, 1, 2, 6, 24]

and
import torch
print((torch.arange(5) + 1).to(torch.float).lgamma().exp())
>>> tensor([ 1.,  1.,  2.,  6., 24.])