Warning: Encountered known unsupported method torch.randn

I was trying to convert my torch model to tensorRT I encountered with this problem.

** Encountered known unsupported method torch.randn**

Please any help regarding this would be appreciated.

Please find the code snippet below

class VAEGen(nn.Module):
# VAE architecture
def init(self, input_dim):
super(VAEGen, self).init()
# dim = params[‘dim’]
# n_downsample = params[‘n_downsample’]
# n_res = params[‘n_res’]
# activ = params[‘activ’]
# pad_type = params[‘pad_type’]

    # content encoder
    self.enc = ContentEncoder(2, 4, 3, 64, 'in', 'relu', pad_type='reflect')
    self.dec = Decoder(2, 4, self.enc.output_dim, 3, res_norm='in', activ='relu', pad_type='reflect')

def forward(self, images):
    # This is a reduced VAE implementation where we assume the outputs are multivariate Gaussian distribution with mean = hiddens and std_dev = all ones.
    hiddens,_ = self.encode(images)
    if self.training == False:
        noise = Variable(torch.randn(hiddens.size()).cuda(hiddens.data.get_device()))
        images_recon = self.decode(hiddens + noise)
    else:
        images_recon = self.decode(hiddens)
    return images_recon, hiddens

def encode(self, images):
    hiddens = self.enc(images)
    noise = Variable(torch.randn(hiddens.size()).cuda(hiddens.data.get_device()))
    return hiddens, noise

def decode(self, hiddens):
    images = self.dec(hiddens)
    return images

Hi,

What are you using to convert your model?
It looks like whatever you’re using does not support the torch.randn function no?

Hi,
i am trying to use torchtotrt developed by NVIDIA to convert my model to tensorRT

cc @ptrblck do you know why this function is not supported?

How are you exporting your model to TensorRT?
Are you using a similar pipeline as this one:
PyTorch -> JIT -> ONNX -> TensorRT

or are you using the Python API of TensorRT?
I would like to reproduce this error, but I would need to know your work flow first.

Yes probably the Instance normalization

Hi,

I am exporting model using torchtotrt developed by NVIDIA please find the link below for the conversion

Hi

I am doing the following way to convert my model