Why the output shape can't be infered in the exported in the onnx graph when registering a custome operator by the Function class

DaZhUUU: <p>why the output shape can’t be infered in the exported in the onnx graph when registering a custome operator by the Function class<br>
here’s my code</p>
<pre><code class="lang-auto">
import torch
import torch.nn as nn
from torch.autograd import Function
import torch.onnx

#custom op onnx representation
class MyStrangeOp(Function):
   #for onnx node representation, symbolic function must be defined and specified static.
   @staticmethod
   def symbolic(g, input, weight, bias, floatAttr, intAttr):
      #because forward function return 2 outputs, so this func also have to return 2 outputs
      #this is my expriment result, I didn't find any docs, fuck it!
      return g.op("MyStrangeOp", input, weight, bias, float_attr_f=floatAttr, int_attr_i=intAttr), \
             g.op("MyStrangeOp", input, weight, bias, float_attr_f=floatAttr, int_attr_i=intAttr)

   @staticmethod
   def forward(ctx, input, weight, bias, floatAttr, intAttr):
      #this op return 2 outputs
      return input + weight, input * weight + bias

myStrangeOpForward = MyStrangeOp.apply

#layer
class MyStrangeOpLayer(nn.Module):
   def __init__(self, weight, bias, floatAttr, intAttr):
      super(MyStrangeOpLayer, self).__init__()
      self.weight = weight
      self.bias = bias
      self.floatAttr = floatAttr
      self.intAttr = intAttr

   def forward(self, x):
      return myStrangeOpForward(x, self.weight, self.bias, self.floatAttr, self.intAttr)

#model
class MyStrangeNet(nn.Module):
   def __init__(self):
      super(MyStrangeNet, self).__init__()
      self.myLayer1 = MyStrangeOpLayer(weight=nn.Parameter(torch.ones(1, 3, 4, 4)), bias=nn.Parameter(torch.ones(1, 3, 4, 4)), floatAttr=[0.1, 0.5], intAttr=[2, 2])
      self.myLayer2 = MyStrangeOpLayer(weight=nn.Parameter(torch.ones(1, 3, 4, 4)), bias=nn.Parameter(torch.ones(1, 3, 4, 4)), floatAttr=[0.5, 0.5], intAttr=[3, 3])
      self.conv1    = nn.Conv2d(in_channels=3, out_channels=3, kernel_size=3, padding=1, stride=1, bias=True)
      self.conv2    = nn.Conv2d(in_channels=3, out_channels=3, kernel_size=3, padding=1, stride=1, bias=True)
      self.conv3    = nn.Conv2d(in_channels=3, out_channels=3, kernel_size=3, padding=1, stride=1, bias=True)
      self.conv4    = nn.Conv2d(in_channels=3, out_channels=3, kernel_size=3, padding=1, stride=1, bias=True)

   def forward(self, x):
      x1, x2 = self.myLayer1(x)
      x3, x4 = self.myLayer2(x)
      x1     = self.conv1(x1)
      x2     = self.conv1(x2)
      x3     = self.conv1(x3)
      x4     = self.conv1(x4)
      return x1 + x2 + x3 + x4

model = MyStrangeNet()
t = torch.ones(1, 3, 4, 4, dtype=torch.float32)
torch.onnx.export(model, (t,), 'fuckIt.onnx', opset_version=13, input_names=["inputTensor"], output_names=["outputTensor"],
             operator_export_type=torch.onnx.OperatorExportTypes.ONNX_ATEN_FALLBACK)
</code></pre>
<p>my exported onnx graph don’t have output shape<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/b/1bf4ff67608a52a2ee659e7514ff94bda8c79139.png" data-download-href="https://discuss.pytorch.org/uploads/default/1bf4ff67608a52a2ee659e7514ff94bda8c79139" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/b/1bf4ff67608a52a2ee659e7514ff94bda8c79139_2_690x289.png" alt="image" data-base62-sha1="3ZjNoRMA4Dk9P0bblTQZhJNtdrP" width="690" height="289" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/b/1bf4ff67608a52a2ee659e7514ff94bda8c79139_2_690x289.png, https://discuss.pytorch.org/uploads/default/optimized/3X/1/b/1bf4ff67608a52a2ee659e7514ff94bda8c79139_2_1035x433.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/1/b/1bf4ff67608a52a2ee659e7514ff94bda8c79139_2_1380x578.png 2x" data-dominant-color="F5F4F3"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1393×584 22.3 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>