MegEngine / mgeconvert

MegEngine到其他框架的转换器
https://megengine.org.cn/
Apache License 2.0
67 stars 15 forks source link

无法转换一个简单的 UNet #5

Closed bigeagle closed 3 years ago

bigeagle commented 3 years ago

环境

1.系统环境:ubuntu 18.04 2.MegEngine版本:MegEngine 1.1 3.python版本:3.6.9

复现步骤

见代码

请提供关键的代码片段便于追查问题

模型见 https://github.com/megvii-research/PMRID/blob/main/models/net_mge.py

先 dump 一个模型出来

from megengine import jit
net = Network()
net.eval()
img = mge.tensor(np.random.randn(1, 4, 64, 64).astype(np.float32))

@jit.trace(capture_as_const=True)
def f(x):
    out = net(x)
    return out

f(img)
f.dump(
    "net.mge",
    arg_names=['img'],
    optimize_for_inference=False,
    output_names=['pred'],
)

请提供完整的日志及报错信息

在将 #4 自己修掉的情况下运行 megconverter:

python3 -m mgeconvert.utils.convert_onnx  -i net.mge -o net.onnx
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/wangyuzhi/.local/lib/python3.6/site-packages/mgeconvert/utils/convert_onnx.py", line 29, in <module>
    main()
  File "/home/wangyuzhi/.local/lib/python3.6/site-packages/mgeconvert/utils/convert_onnx.py", line 25, in main
    convert_to_onnx(args.input, args.output, graph_name=args.graph, opset=args.opset)
  File "/home/wangyuzhi/.local/lib/python3.6/site-packages/mgeconvert/onnx_converter/onnx_converter.py", line 120, in convert_to_onnx
    model = converter.convert()
  File "/home/wangyuzhi/.local/lib/python3.6/site-packages/mgeconvert/onnx_converter/onnx_converter.py", line 70, in convert
    unsupported_oprs
AssertionError: Operators {<class 'mgeconvert.mge_context.mge_op.ConvolutionBackwardDataOpr'>} are not supported yet

我不了解 ConvolutionBackwardDataOpr 这个 opr 的作用,凭我朴素的理解,我只需要得到这个网络的前向部分,跟 backward 应该没关系……

dingshaohua960303 commented 3 years ago

@bigeagle 您好,ConvolutionBackwardData 是 megengine 中的 conv_transpose2d,目前还没有实现该opr到caffe/onnx的转换,我们会在近期添加该opr的转换器。