Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
b622064a
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
403
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
b622064a
编写于
1月 30, 2023
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mge/network): add init parameters for some op nodes
GitOrigin-RevId: 6515c961b7745593ecc280b659527527f362c8fa
上级
c0b9e071
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
45 addition
and
0 deletion
+45
-0
imperative/python/megengine/utils/network_node.py
imperative/python/megengine/utils/network_node.py
+14
-0
imperative/python/test/unit/utils/test_network_node.py
imperative/python/test/unit/utils/test_network_node.py
+31
-0
未找到文件。
imperative/python/megengine/utils/network_node.py
浏览文件 @
b622064a
...
...
@@ -392,6 +392,14 @@ class MatrixMul(OpNode):
type
=
"MatrixMul"
opdef
=
builtin
.
MatrixMul
@
classmethod
def
load
(
cls
,
opr
):
obj
=
super
(
MatrixMul
,
cls
).
load
(
opr
)
dim1
,
dim2
=
len
(
opr
.
inputs
[
0
].
shape
),
len
(
opr
.
inputs
[
1
].
shape
)
obj
.
params
[
"dimA"
]
=
dim1
obj
.
params
[
"dimB"
]
=
dim2
return
obj
@
register_flops
(
MatrixMul
)
def
flops_matmul
(
opnode
:
MatrixMul
,
inputs
,
outputs
):
...
...
@@ -431,6 +439,12 @@ class ConvolutionBackwardData(OpNode):
type
=
"ConvTranspose"
opdef
=
builtin
.
ConvolutionBackwardData
@
classmethod
def
load
(
cls
,
opr
):
obj
=
super
(
ConvolutionBackwardData
,
cls
).
load
(
opr
)
obj
.
params
[
"dtype"
]
=
opr
.
outputs
[
0
].
dtype
return
obj
class
DeformableConvForward
(
OpNode
):
type
=
"DeformableConv"
...
...
imperative/python/test/unit/utils/test_network_node.py
浏览文件 @
b622064a
import
io
import
os
import
platform
from
contextlib
import
contextmanager
import
numpy
as
np
import
pytest
...
...
@@ -12,6 +13,7 @@ import megengine.functional as F
import
megengine.module
as
M
import
megengine.random
as
rand
from
megengine.core._imperative_rt.core2
import
apply
from
megengine.core._trace_option
import
set_symbolic_shape
,
use_symbolic_shape
from
megengine.core._wrap
import
Device
from
megengine.core.ops
import
builtin
from
megengine.device
import
(
...
...
@@ -26,6 +28,14 @@ from megengine.utils.comp_graph_tools import GraphInference
from
megengine.utils.network
import
Network
as
Net
@
contextmanager
def
override_symbolic_shape
(
enable
:
bool
):
old
=
use_symbolic_shape
()
set_symbolic_shape
(
enable
)
yield
set_symbolic_shape
(
old
)
def
check_pygraph_dump
(
trace_func
,
inp_data
,
expect_results
,
max_err
=
None
):
orig_model
=
io
.
BytesIO
()
inp_size
=
len
(
inp_data
)
...
...
@@ -41,6 +51,16 @@ def check_pygraph_dump(trace_func, inp_data, expect_results, max_err=None):
orig_model
.
seek
(
0
)
net
=
Net
.
load
(
orig_model
)
# make a graph transform
with
override_symbolic_shape
(
False
):
old_inps
=
net
.
input_vars
new_inps
=
[
net
.
make_input_node
(
shape
=
inp
.
shape
,
dtype
=
inp
.
dtype
,
name
=
inp
.
name
)
for
inp
in
old_inps
]
net
.
replace_vars
(
dict
(
zip
(
old_inps
,
new_inps
)))
file
=
io
.
BytesIO
()
net
.
dump
(
file
,
optimize_for_inference
=
False
)
file
.
seek
(
0
)
...
...
@@ -207,6 +227,17 @@ def test_convtranspose():
check_pygraph_dump
(
fwd
,
[
data
],
[
result
],
5
)
def
test_convtranspose_int8
():
@
trace
(
symbolic
=
True
,
capture_as_const
=
True
)
def
fwd
(
inp
,
weight
):
return
F
.
quantized
.
conv_transpose2d
(
inp
,
weight
,
dtype
=
dtype
.
qint8
(
scale
=
1.0
))
inp
=
Tensor
(
np
.
random
.
random
((
1
,
16
,
64
,
64
)),
dtype
=
dtype
.
qint8
(
scale
=
1.0
))
weight
=
Tensor
(
np
.
random
.
random
((
16
,
16
,
4
,
4
)),
dtype
=
dtype
.
qint8
(
scale
=
1.0
))
result
=
fwd
(
inp
,
weight
)
check_pygraph_dump
(
fwd
,
[
inp
,
weight
],
[
result
])
@
pytest
.
mark
.
skip
(
reason
=
"pytest aborted"
)
def
test_grouplocal
():
n
=
M
.
LocalConv2d
(
3
,
32
,
32
,
32
,
3
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录