Warning: Encountered known unsupported method torch.randn

username: kshama
cooked: <p>I was trying to convert my torch model to tensorRT I encountered with this problem.</p>
<p>** Encountered known unsupported method torch.randn**</p>
<p>Please any help regarding this would be appreciated.</p>
<p>Please find the code snippet below</p>
<p>class VAEGen(nn.Module):<br>
# VAE architecture<br>
def <strong>init</strong>(self, input_dim):<br>
super(VAEGen, self).<strong>init</strong>()<br>
# dim = params[‘dim’]<br>
# n_downsample = params[‘n_downsample’]<br>
# n_res = params[‘n_res’]<br>
# activ = params[‘activ’]<br>
# pad_type = params[‘pad_type’]</p>
<pre><code>    # 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</code></pre>

username: albanD
cooked: <p>Hi,</p>
<p>What are you using to convert your model?<br>
It looks like whatever you’re using does not support the <code>torch.randn</code> function no?</p>

username: kshama
cooked: <p>Hi,<br>
i am trying to use torchtotrt developed by NVIDIA to convert my model to tensorRT</p>

username: albanD
cooked: <p>cc <a class="mention" href="/u/ptrblck">@ptrblck</a> do you know why this function is not supported?</p>

username: ptrblck
cooked: <p>How are you exporting your model to TensorRT?<br>
Are you using a similar pipeline as this one:<br>
PyTorch -&gt; JIT -&gt; ONNX -&gt; TensorRT</p>
<p>or are you using the Python API of TensorRT?<br>
I would like to reproduce this error, but I would need to know your work flow first.</p>

username: kshama
cooked: <p>Yes probably the Instance normalization</p>

username: kshama
cooked: <p>Hi,</p>
<p>I am exporting model using torchtotrt developed by NVIDIA please find the link below for the conversion</p>
<aside class="onebox whitelistedgeneric">
  <header class="source">
      <img src="https://github.githubassets.com/favicon.ico" class="site-icon" width="16" height="16">
      <a href="https://github.com/NVIDIA-AI-IOT/torch2trt/tree/master/torch2trt" target="_blank" rel="nofollow noopener">GitHub</a>
  </header>
  <article class="onebox-body">
    <img src="https://avatars1.githubusercontent.com/u/29582968?s=400&amp;v=4" class="thumbnail onebox-avatar" width="60" height="60">

<h3><a href="https://github.com/NVIDIA-AI-IOT/torch2trt/tree/master/torch2trt" target="_blank" rel="nofollow noopener">NVIDIA-AI-IOT/torch2trt</a></h3>

<p>An easy to use PyTorch to TensorRT converter. Contribute to NVIDIA-AI-IOT/torch2trt development by creating an account on GitHub.</p>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>


username: kshama
cooked: <p>Hi</p>
<p>I am doing the following way to convert my model<br>
<aside class="onebox whitelistedgeneric">
  <header class="source">
      <img src="https://github.githubassets.com/favicon.ico" class="site-icon" width="16" height="16">
      <a href="https://github.com/NVIDIA-AI-IOT/torch2trt/tree/master/torch2trt" target="_blank" rel="nofollow noopener">GitHub</a>
  </header>
  <article class="onebox-body">
    <img src="https://avatars1.githubusercontent.com/u/29582968?s=400&amp;v=4" class="thumbnail onebox-avatar" width="60" height="60">

<h3><a href="https://github.com/NVIDIA-AI-IOT/torch2trt/tree/master/torch2trt" target="_blank" rel="nofollow noopener">NVIDIA-AI-IOT/torch2trt</a></h3>

<p>An easy to use PyTorch to TensorRT converter. Contribute to NVIDIA-AI-IOT/torch2trt development by creating an account on GitHub.</p>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>
</p>