title: Can't convert Pytorch to ONNX
body: <p>Trying to convert <a href="https://github.com/zllrunning/face-parsing.PyTorch" rel="nofollow noreferrer">this</a> pytorch model with ONNX gives me this error. I've searched github and this error came up before in version 1.1.0 but was apparently rectified. Now I'm on torch 1.4.0. (python 3.6.9) and I see this error.</p>
  
  <pre><code>File "/usr/local/lib/python3.6/dist-packages/torch/onnx/init.py", line 148, in export
  strip_doc_string, dynamic_axes, keep_initializers_as_inputs)
  File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 66, in export
  dynamic_axes=dynamic_axes, keep_initializers_as_inputs=keep_initializers_as_inputs)
  File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 416, in _export
  fixed_batch_size=fixed_batch_size)
  File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 296, in _model_to_graph
  fixed_batch_size=fixed_batch_size, params_dict=params_dict)
  File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 135, in _optimize_graph
  graph = torch._C._jit_pass_onnx(graph, operator_export_type)
  File "/usr/local/lib/python3.6/dist-packages/torch/onnx/init.py", line 179, in _run_symbolic_function
  return utils._run_symbolic_function(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py", line 657, in _run_symbolic_function
  return op_fn(g, *inputs, **attrs)
  File "/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_helper.py", line 128, in wrapper
  args = [_parse_arg(arg, arg_desc) for arg, arg_desc in zip(args, arg_descriptors)]
  File "/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_helper.py", line 128, in
  args = [_parse_arg(arg, arg_desc) for arg, arg_desc in zip(args, arg_descriptors)]
  File "/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_helper.py", line 81, in _parse_arg
  "', since it's not constant, please try to make "
  RuntimeError: Failed to export an ONNX attribute 'onnx::Gather', since it's not constant, please try to make things (e.g., kernel size) static if possible
  </code></pre>
  
  <p>How to fix it? I've also tried latest nightly build, same error comes up.</p>
  
  <p>My code:</p>
  
  <pre><code>from model import BiSeNet
  import torch.onnx
  import torch
  
  net = BiSeNet(19)
  net.cuda()
  net.load_state_dict(torch.load('/content/drive/My Drive/Collab/fp/res/cp/79999_iter.pth'))
  net.eval()
  
  dummy = torch.rand(1,3,512,512).cuda()
  torch.onnx.export(net, dummy, "Model.onnx", input_names=["image"], output_names=["output"])
  </code></pre>
  
  <p>I added <code>print (v.node ())</code> to symbolic_helper.py just before the runtime error is raised to see what's causing the error.</p>
  
  <p>This is the output: <code>%595 : Long() = onnx::Gather[axis=0](%592, %594) # /content/drive/My Drive/Collab/fp/model.py:111:0</code></p>
  
  <p>And that line in 111 in model.py is: <code>avg = F.avg_pool2d(feat32, feat32.size()[2:])</code></p>
  
  <p>This <a href="https://translate.google.com/translate?hl=en&amp;sl=auto&amp;tl=en&amp;u=http%3A%2F%2Fwww.msdn.hk%2Fwzfwq%2F60524.html" rel="nofollow noreferrer">source</a> suggests that tensor.size method in pytorch cannot be recognized by onnx and needs to be modified into a constant.</p>