murdockhou / Yet-Another-EfficientDet-Pytorch-Convert-ONNX-TVM

GNU Lesser General Public License v3.0
59 stars 17 forks source link

Cannot convert to ONNX using pytorch 1.1.0 #3

Open haoranchen1104 opened 4 years ago

haoranchen1104 commented 4 years ago

Thanks for the great work of your repo. However, it's not working under pytorch1.1.0 and raise RuntimeError.

RuntimeError: Failed to export an ONNX attribute, since it's not constant, please try to make things (e.g., kernel size) static if possible

Using pytorch 1.2.0 I uncommented the two lines in backbone.py and the code is like

        # if you just want to convert to onnx, you can cancel the two lines of comments
        # or, if you want convert to tvm, just return regression and classification

        anchors = self.anchors(inputs, inputs.dtype)
        return features, regression, classification, anchors

        # return regression, classification

This time, torch.onnx would work, but the print output was strange.

... ...
  %2665 : Float(1, 46917!, 4!) = onnx::Constant[valutdet\Yet-Another-EfficientDet-Pytet\model.py:377:0e=<Tensor>]()                                                                        ssifier[classifier] # G:\COMPETITION\planer\efficientdet\Yet-Anothe
  return (%2353, %2415, %2477, %2539, %2601, %2352, e=<Tensor>]()
%2664, %2665)  

Don't know why there is ! in Float(1, 46917!, 4!).

murdockhou commented 4 years ago

@Modrizil Hi,we use Pytorch 1.4.0, maybe you can try this.