Convert pytorch to onnx about the operator mv

nick_zhang: <h1>background</h1>
<p>I want to convert model to ONNX, but there is the <em>mv</em> operator in my model, so when run <code>torch.onnx.export</code>, console output the error:</p>
<pre><code class="lang-auto">RuntimeError:exporting the operator mv to ONNX opset version 11 is not supported. Please feel free to request support or submit a pull request on Pytorch Github
</code></pre>
<p>so, I have to implement <em>mv</em> operator for ONNX support.</p>
<h1>question</h1>
<ul>
<li>how to confirm the operator is an <em>ATen operator</em>.<br>
This <a href="https://pytorch.org/docs/stable/onnx.html#aten-operators" rel="noopener nofollow ugc">document</a> says that <code>If the operator is an ATen operator, which means you can find the declaration of the function in torch/csrc/autograd/generated/VariableType.h </code>, but in this header file, these is not any operator declaration, if I have the mistaken about the <code>function declaration </code>.</li>
</ul>
<h1>VariableType.h info</h1>
<pre><code class="lang-auto">#pragma once
// @generated from tools/autograd/templates/VariableType.h
#include &lt;ATen/ATen.h&gt;
#include &lt;c10/util/intrusive_ptr.h&gt;
#include &lt;torch/csrc/WindowsTorchApiMacro.h&gt;
#include &lt;cstdint&gt; // for size_t
#include &lt;functional&gt; // for function
#include &lt;memory&gt; // for unique_ptr
#include &lt;string&gt;
#include &lt;vector&gt;
namespace at {
  struct Quantizer;
};
namespace torch { namespace autograd {
using Variable = at::Tensor;
using at::Context;
using at::Device;
using at::Dimname;
using at::DimnameList;
using at::Generator;
using at::IntArrayRef;
using at::MemoryFormat;
using at::QScheme;
using at::Scalar;
using at::ScalarType;
using at::Storage;
using at::Tensor;
using at::TensorList;
using at::TensorOptions;
using at::Quantizer;
// This is temporary typedef to enable Quantizer in aten native function API
// we'll remove them when we are actually exposing Quantizer class
// to frontend
using ConstQuantizerPtr = const c10::intrusive_ptr&lt;Quantizer&gt;&amp;;
using c10::optional;
namespace VariableType {
  TORCH_API std::vector&lt;at::DeprecatedTypeProperties*&gt; allCUDATypes();
  TORCH_API std::vector&lt;at::DeprecatedTypeProperties*&gt; allCPUTypes();
  at::Tensor &amp; unpack(Tensor &amp; t, const char * name, int pos);
  const at::Tensor &amp; unpack(const Tensor &amp; t, const char * name, int pos);
  at::Tensor unpack_opt(const Tensor &amp; t, const char * name, int pos);
  std::vector&lt;at::Tensor&gt; unpack(at::TensorList tl, const char *name, int pos);
};
}} // namespace torch::autograd
</code></pre>
<h1>the code for reproduce the error</h1>
<pre><code class="lang-auto">from torch.autograd import Variable
import torch


class custom_net(torch.nn.Module):

    def __init__(self,):
        super(custom_net, self).__init__()
        self.sigmoid = torch.nn.Sigmoid()

    def forward(self, martix, vector):
        martix = self.sigmoid(martix)
        vector = self.sigmoid(vector)
        outputs = torch.mv(martix, vector)
        return outputs


if __name__ == "__main__":

    net = custom_net()
    net = net.eval().cuda()
    martix = Variable(torch.randn(2, 3)).type(torch.FloatTensor)
    vector = Variable(torch.randn(3)).type(torch.FloatTensor)

    martix = martix.cuda()
    vector = vector.cuda()

    input_name = ["martix", "vector"]
    output_name = ["output"]

    torch.onnx.export(net, (martix, vector), "net.onnx", input_names=input_name, output_names=output_name,
                      opset_version=11)
    print("done!")
</code></pre>

eddiekindergarten: <p>Same question, did you solve it yet? <a class="mention" href="/u/nick_zhang">@nick_zhang</a></p>

li_he: <p>Does anyone have an solution?</p>

li_he: <p>哥们，解决了没，有什么方法？？？？？？？？</p>

ptrblck: <p>From Google translate:</p>
<blockquote>
<p>Dude, have you solved it, is there any way?</p>
</blockquote>
<p><a class="mention" href="/u/li_he">@li_he</a> please use an online translation service so that other can also help.</p>