<h2 dir="auto">🐛 Bug</h2>
<p dir="auto">RuntimeError: Exporting the operator affine_grid_generator to ONNX opset version 11 is not supported. Please open a bug to request ONNX export support for the missing operator.</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior:</p>
<ol dir="auto">
<li>Just trying to convert this pytorch project in link to onnx model, using the code below in eval.py</li>
</ol>
<p dir="auto">"<a href="https://github.com/D-X-Y/landmark-detection/tree/master/SBR">https://github.com/D-X-Y/landmark-detection/tree/master/SBR</a>"</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="inputs = image.unsqueeze(0)
net.to(torch.device('cpu'))
input_names = [ &quot;actual_input_1&quot; ] + [ &quot;learned_%d&quot; % i for i in range(72) ]
output_names = [ &quot;output1&quot;, &quot;output2&quot;]
torch.onnx.export(net,      # model being run
        inputs,                         # model input (or a tuple for multiple inputs)
        &quot;sbr.onnx&quot;,                # where to save the model (can be a file or file-like object)
        verbose=True, input_names=input_names, output_names=output_names
       ,operator_export_type=torch.onnx.OperatorExportTypes.ONNX_ATEN_FALLBACK
        ,opset_version=12                  
        )"><pre class="notranslate"><code class="notranslate">inputs = image.unsqueeze(0)
net.to(torch.device('cpu'))
input_names = [ "actual_input_1" ] + [ "learned_%d" % i for i in range(72) ]
output_names = [ "output1", "output2"]
torch.onnx.export(net,      # model being run
        inputs,                         # model input (or a tuple for multiple inputs)
        "sbr.onnx",                # where to save the model (can be a file or file-like object)
        verbose=True, input_names=input_names, output_names=output_names
       ,operator_export_type=torch.onnx.OperatorExportTypes.ONNX_ATEN_FALLBACK
        ,opset_version=12                  
        )
</code></pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">Obtaining onnx model file correctly</p>
<h2 dir="auto">Environment</h2>
<p dir="auto">PyTorch version: 1.6.0a0+f6b1c04<br>
Is debug build: No<br>
CUDA used to build PyTorch: 10.2</p>
<p dir="auto">OS: Ubuntu 18.04.4 LTS<br>
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0<br>
CMake version: version 3.17.2</p>
<p dir="auto">Python version: 3.6<br>
Is CUDA available: Yes<br>
CUDA runtime version: Could not collect<br>
GPU models and configuration: GPU 0: GeForce GTX 1050 Ti<br>
Nvidia driver version: 440.64.00<br>
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5</p>
<p dir="auto">Versions of relevant libraries:<br>
[pip] numpy==1.18.4<br>
[pip] torch==1.6.0a0+f6b1c04<br>
[conda] blas                      1.0                         mkl<br>
[conda] libblas                   3.8.0                    15_mkl    conda-forge<br>
[conda] libcblas                  3.8.0                    15_mkl    conda-forge<br>
[conda] liblapack                 3.8.0                    15_mkl    conda-forge<br>
[conda] magma-cuda102             2.5.2                         1    pytorch<br>
[conda] mkl                       2019.0                   pypi_0    pypi<br>
[conda] mkl-include               2019.0                   pypi_0    pypi<br>
[conda] mkl-service               2.3.0            py36he904b0f_0<br>
[conda] mkl_fft                   1.0.15           py36ha843d7b_0<br>
[conda] mkl_random                1.1.0            py36hd6b4f25_0<br>
[conda] numpy                     1.18.2                   pypi_0    pypi<br>
[conda] numpy-base                1.18.1           py36hde5b4d6_1<br>
[conda] torch                     1.6.0a0+f6b1c04           dev_0    </p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/houseroad/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/houseroad">@houseroad</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/spandantiwari/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/spandantiwari">@spandantiwari</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/lara-hdr/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/lara-hdr">@lara-hdr</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/BowenBao/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/BowenBao">@BowenBao</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/neginraoof/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/neginraoof">@neginraoof</a></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import torch
import torch.nn as nn


class Model(nn.Module):
  def __init__(self):
    super(Model, self).__init__()

  def forward(self, theta, size):
    return torch.nn.functional.affine_grid(theta, size, align_corners=None)


model = Model()
theta = torch.ones((1, 2, 3))
size = torch.Size((1,3,24,24))
torch.onnx.export(model, (theta, size), 'test.onnx', verbose=True)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">torch</span>
<span class="pl-k">import</span> <span class="pl-s1">torch</span>.<span class="pl-s1">nn</span> <span class="pl-k">as</span> <span class="pl-s1">nn</span>


<span class="pl-k">class</span> <span class="pl-v">Model</span>(<span class="pl-s1">nn</span>.<span class="pl-v">Module</span>):
  <span class="pl-k">def</span> <span class="pl-en">__init__</span>(<span class="pl-s1">self</span>):
    <span class="pl-en">super</span>(<span class="pl-v">Model</span>, <span class="pl-s1">self</span>).<span class="pl-en">__init__</span>()

  <span class="pl-k">def</span> <span class="pl-en">forward</span>(<span class="pl-s1">self</span>, <span class="pl-s1">theta</span>, <span class="pl-s1">size</span>):
    <span class="pl-k">return</span> <span class="pl-s1">torch</span>.<span class="pl-s1">nn</span>.<span class="pl-s1">functional</span>.<span class="pl-en">affine_grid</span>(<span class="pl-s1">theta</span>, <span class="pl-s1">size</span>, <span class="pl-s1">align_corners</span><span class="pl-c1">=</span><span class="pl-c1">None</span>)


<span class="pl-s1">model</span> <span class="pl-c1">=</span> <span class="pl-v">Model</span>()
<span class="pl-s1">theta</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-en">ones</span>((<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>))
<span class="pl-s1">size</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-v">Size</span>((<span class="pl-c1">1</span>,<span class="pl-c1">3</span>,<span class="pl-c1">24</span>,<span class="pl-c1">24</span>))
<span class="pl-s1">torch</span>.<span class="pl-s1">onnx</span>.<span class="pl-en">export</span>(<span class="pl-s1">model</span>, (<span class="pl-s1">theta</span>, <span class="pl-s1">size</span>), <span class="pl-s">'test.onnx'</span>, <span class="pl-s1">verbose</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)</pre></div>
<p dir="auto">Result:<br>
<code class="notranslate">RuntimeError: Exporting the operator affine_grid_generator to ONNX opset version 9 is not supported.</code></p>