I’m converting another model into jit tracer and keep getting a tracer warning for the code below. I’m only passing a function from the original model class.
def reparametrize(self, mu, logvar):
std = logvar.mul(0.5).exp_()
if cfg.CUDA:
eps = torch.cuda.FloatTensor(std.size()).normal_()
else:
eps = torch.FloatTensor(std.size()).normal_()
eps = Variable(eps)
return eps.mul(std).add_(mu)
model.py:192: TracerWarning: Converting a tensor to a Python index might
cause the trace to be incorrect. We can't record the data flow of Python
values, so this value will be treated as a constant in the future. This
means that the trace might not generalize to other inputs!
eps = torch.FloatTensor(std.size()).normal_()
I already checked the passing argument “std.size()” if it’s an python index data type but it’s torch
torch.Size([2, 100]) <class 'torch.Size'>
While eps is also converted to FloatTensor. It makes me confused what is being converted into a python index and don’t know where to start.