Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
oneflow_convert_tools
提交
3adae34a
O
oneflow_convert_tools
项目概览
Oneflow-Inc
/
oneflow_convert_tools
上一次同步 2 年多
通知
1
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oneflow_convert_tools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3adae34a
编写于
9月 18, 2021
作者:
B
BBuf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix convert bug
上级
9e266cab
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
9 addition
and
8 deletion
+9
-8
examples/oneflow2onnx/models/test_alexnet.py
examples/oneflow2onnx/models/test_alexnet.py
+4
-4
oneflow_onnx/oneflow2onnx/flow2onnx.py
oneflow_onnx/oneflow2onnx/flow2onnx.py
+2
-0
oneflow_onnx/oneflow2onnx/util.py
oneflow_onnx/oneflow2onnx/util.py
+2
-3
oneflow_onnx/onnx_wrapper.py
oneflow_onnx/onnx_wrapper.py
+1
-1
未找到文件。
examples/oneflow2onnx/models/test_alexnet.py
浏览文件 @
3adae34a
...
@@ -36,7 +36,7 @@ class AlexNet(nn.Module):
...
@@ -36,7 +36,7 @@ class AlexNet(nn.Module):
nn
.
ReLU
(
inplace
=
True
),
nn
.
ReLU
(
inplace
=
True
),
nn
.
MaxPool2d
(
kernel_size
=
3
,
stride
=
2
),
nn
.
MaxPool2d
(
kernel_size
=
3
,
stride
=
2
),
)
)
self
.
avgpool
=
nn
.
A
daptiveAvgPool2d
((
6
,
6
))
self
.
avgpool
=
nn
.
A
vgPool2d
((
1
,
1
))
self
.
classifier
=
nn
.
Sequential
(
self
.
classifier
=
nn
.
Sequential
(
nn
.
Dropout
(),
nn
.
Dropout
(),
nn
.
Linear
(
256
*
6
*
6
,
4096
),
nn
.
Linear
(
256
*
6
*
6
,
4096
),
...
@@ -48,10 +48,10 @@ class AlexNet(nn.Module):
...
@@ -48,10 +48,10 @@ class AlexNet(nn.Module):
)
)
def
forward
(
self
,
x
:
flow
.
Tensor
)
->
flow
.
Tensor
:
def
forward
(
self
,
x
:
flow
.
Tensor
)
->
flow
.
Tensor
:
x
=
self
.
features
(
x
)
#
x = self.features(x)
x
=
self
.
avgpool
(
x
)
x
=
self
.
avgpool
(
x
)
x
=
flow
.
flatten
(
x
,
1
)
#
x = flow.flatten(x, 1)
x
=
self
.
classifier
(
x
)
#
x = self.classifier(x)
return
x
return
x
alexnet
=
AlexNet
()
alexnet
=
AlexNet
()
...
...
oneflow_onnx/oneflow2onnx/flow2onnx.py
浏览文件 @
3adae34a
...
@@ -188,6 +188,8 @@ def FlowOnnxMapping(g, ops_mapping):
...
@@ -188,6 +188,8 @@ def FlowOnnxMapping(g, ops_mapping):
continue
continue
op
=
node
.
op_type
op
=
node
.
op_type
if
op
==
"output"
:
continue
map_info
=
ops_mapping
.
get
(
op
)
map_info
=
ops_mapping
.
get
(
op
)
if
map_info
is
None
:
if
map_info
is
None
:
unmapped_op
[
op
]
+=
1
unmapped_op
[
op
]
+=
1
...
...
oneflow_onnx/oneflow2onnx/util.py
浏览文件 @
3adae34a
...
@@ -122,12 +122,11 @@ def convert_to_onnx_and_check(
...
@@ -122,12 +122,11 @@ def convert_to_onnx_and_check(
ipt_dict
,
onnx_res
=
run_onnx
(
ipt_dict
,
onnx_res
=
run_onnx
(
onnx_model_path
,
[
"CPUExecutionProvider"
],
ort_optimize
=
ort_optimize
onnx_model_path
,
[
"CPUExecutionProvider"
],
ort_optimize
=
ort_optimize
)
)
oneflow_res
=
graph
(
*
ipt_dict
.
values
(
))
oneflow_res
=
graph
(
flow
.
tensor
(
*
ipt_dict
.
values
(),
dtype
=
flow
.
float32
))
if
not
isinstance
(
oneflow_res
,
np
.
ndarray
):
if
not
isinstance
(
oneflow_res
,
np
.
ndarray
):
oneflow_res
=
oneflow_res
.
get
().
numpy
()
oneflow_res
=
oneflow_res
.
numpy
()
compare_result
(
oneflow_res
,
onnx_res
,
print_outlier
=
print_outlier
)
compare_result
(
oneflow_res
,
onnx_res
,
print_outlier
=
print_outlier
)
flow
.
clear_default_session
()
# cleanup()
# cleanup()
oneflow_onnx/onnx_wrapper.py
浏览文件 @
3adae34a
...
@@ -182,7 +182,7 @@ class Node(object):
...
@@ -182,7 +182,7 @@ class Node(object):
# return self.op_type in ["Const", "ConstV2"]
# return self.op_type in ["Const", "ConstV2"]
def
is_graph_output
(
self
):
def
is_graph_output
(
self
):
return
self
.
op_type
in
[
"
return
"
]
return
self
.
op_type
in
[
"
output
"
]
def
is_graph_input
(
self
):
def
is_graph_input
(
self
):
return
self
.
op_type
in
[
"input"
]
return
self
.
op_type
in
[
"input"
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录