megengine / mgeconvert Goto Github PK
View Code? Open in Web Editor NEWMegEngine到其他框架的转换器
Home Page: https://megengine.org.cn/
License: Apache License 2.0
MegEngine到其他框架的转换器
Home Page: https://megengine.org.cn/
License: Apache License 2.0
master源码安装,TracedModule 转换到 caffe 的时候由于参数问题会报错,没有outspec
Traceback (most recent call last):
File "/home/lvhaoran/.local/bin/convert", line 187, in <module>
main()
File "/home/lvhaoran/.local/bin/convert", line 180, in main
args.func(args)
File "/home/lvhaoran/.local/bin/convert", line 31, in to_caffe
args.input, prototxt=args.prototxt, caffemodel=args.caffemodel, outspec=outspec
TypeError: tracedmodule_to_caffe() got an unexpected keyword argument 'outspec'
如题,方便使用MegEngine实现推理部署端的加速
改变.mge模型与权重参数,得到的onnx模型具有相同的结果,相同的权重,且结构与原.mge模型不一致
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 应该没关系……
mgeconvert1.0.2版本,onnx模型转mge,报错:
05 09:32:46[mgb] ERR error occurred in computing sequence; synchronizing all comp nodes and releasing vars now ...
RuntimeError: nvrtc compile error: default_program(2): catastrophic error: cannot open source file "cuda_fp16.h"
系统里cuda_fp16.h在/usr/local/cuda-10.1/targets/x86_64-linux/include 这个目录下,请问要如何设置能让mgeconvert找到这个头文件?
1.需要支持下reducemax\tile;
2.另外Unsqueeze是有问题的;
3.onnx和onnxsim建议安装的版本好像没有,有一些低版本会有bug
在onnx模型转mge模型时候无法正常运行,卡在下面这个位置点不动了。
from mgeconvert.converters.onnx_to_mge import onnx_to_mge
onnx_to_mge( 'onnx2.onnx', output="mge.mge", )
ONNX Model Producer : pytorch
ONNX Model Producer Version: 1.8
ONNX Model IR Version : 6
ONNX Model OpSet : 11
`
https://github.com/MegEngine/mgeconvert/blob/master/mgeconvert/mge_context/mge_op.py#L302
class ConvolutionBackwardDataOpr(MgeOpr):
name = "ConvolutionBackwardData"
def __init__(self, opr):
super().__init__(opr)
self.kernel_shape = get_shape(opr.inputs[1])
self.data_format = opr.params["format"]
self.dilation_w = opr.params["dilate_w"]
self.dilation_h = opr.params["dilate_h"]
self.pad_w = opr.params["pad_w"]
self.pad_h = opr.params["pad_h"]
self.stride_w = opr.params["stride_w"]
self.stride_h = opr.params["stride_h"]
self.sparse = opr.params["sparse"]
这里应该使用 self.params
meg 和 mge 的区别是啥呢
是否支持多输入多输出的mge到onnx转化
这样我就可以在手机上折腾这些东西了
你好!
如题,报错如下:
convert: error: invalid choice: 'mge_to_onnx' (choose from 'onnx')
但是convert onnx ... 却可以, 请问知道是什么原因吗 ?
谢谢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.