Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

带bias的linear层转onnx,为什么转换成Gemm+Add? #20

Closed
ZipengFeng opened this issue Jun 8, 2021 · 1 comment
Closed

带bias的linear层转onnx,为什么转换成Gemm+Add? #20

ZipengFeng opened this issue Jun 8, 2021 · 1 comment

Comments

@ZipengFeng
Copy link

测试函数为:
test/test_onnx.py/test_linear()

onnx结果:
image

带bias的linear层转换成Gemm+Add,不带bias的linear层转换成Gemm。其中Gemm的bias都是为1维。

是否应该改为:
带bias的linear层转换成Gemm,其中gemm的bias为oc维;
不带bias的linear层转换成Gemm, bias为空?

@lixiangyin666
Copy link
Collaborator

目前,目前我们的mgeconvert是基于dump出的细粒度cpp图的,由于python层linear的实现是matmul + add,导致dump出的mge的op也是matmul + add,从而导致转到onnx也是matmul + add。
针对这个问题,我们在caffe转换器中加了pattern match以解决conv+bias, linear + bias的问题,见代码,后续我们重构一下,在解析mge层实现这种策略以支持onnx等其他框架。
另外,我们正在开发更高层表达的traced module以彻底解决这些问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants