Encountered known unsupported method torch.randn/torch.Tensor.get_device/torch.Tensor.cuda

I am not able to solve this issue. Don’t know what could be the reason for this issue .

Please any feedback to this would be appreciated .

Please find model below and also the way I am trying to convert to the torch model tensorRT is also provided 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)
            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