inisis / brocolli

Everything in Torch Fx
MIT License
341 stars 63 forks source link

pytorch transform error #4

Closed allendred closed 5 years ago

allendred commented 5 years ago

Something wrong about "align_corners" in function "upsample".

Detail: TypeError: upsample_bilinear2d() got an unexpected keyword argument 'align_corners' (occurred when translating upsample_bilinear2d)

inisis commented 5 years ago

Hi,

first please make sure that u r using pytorch 0.4.0.

then go to your /usr/lib/python3.6/site-packages/torch/onnx or your virtual env lib/python3.6/site-packages/torch/onnx

replace utils.py line 362 with attrs = {k: n[k] for k in n.attributeNames() if k != 'align_corners'}

replace symbolic.py line 461-466 with

def upsample_bilinear2d(g, input, output_size): input_shape_str = re.findall(r'[^()!]+', str(input))[2].split(',') w_scale = float(output_size[-1]) / float(input_shape_str[-1]) h_scale = float(output_size[-2]) / float(input_shape_str[-2]) return g.op("Upsample", input, channel_s=input_shape_str[1], width_scale_f=w_scale, height_scale_f=h_scale, mode_s="bilinear")

inisis commented 5 years ago

I will close this issue, u can reopen it if there is any update