Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
8ec4883c
X
X2Paddle
项目概览
PaddlePaddle
/
X2Paddle
大约 1 年 前同步成功
通知
328
Star
698
Fork
167
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
26
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
X2Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
26
Issue
26
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8ec4883c
编写于
4月 14, 2021
作者:
S
SunAhong1993
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the unpack
上级
3cf6f557
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
16 addition
and
6 deletion
+16
-6
x2paddle/core/program.py
x2paddle/core/program.py
+13
-6
x2paddle/op_mapper/dygraph/onnx2paddle/opset9/opset.py
x2paddle/op_mapper/dygraph/onnx2paddle/opset9/opset.py
+3
-0
未找到文件。
x2paddle/core/program.py
浏览文件 @
8ec4883c
...
@@ -76,6 +76,7 @@ class PaddleGraph(object):
...
@@ -76,6 +76,7 @@ class PaddleGraph(object):
self
.
source_type
=
source_type
self
.
source_type
=
source_type
self
.
custom_code
=
None
self
.
custom_code
=
None
self
.
inputs_info
=
None
self
.
inputs_info
=
None
self
.
has_unpack
=
False
def
set_name
(
self
,
name
):
def
set_name
(
self
,
name
):
self
.
name
=
name
.
replace
(
"-"
,
"_"
).
replace
(
"/"
,
"_"
)
self
.
name
=
name
.
replace
(
"-"
,
"_"
).
replace
(
"/"
,
"_"
)
...
@@ -112,6 +113,8 @@ class PaddleGraph(object):
...
@@ -112,6 +113,8 @@ class PaddleGraph(object):
layer_id
)
layer_id
)
layer
=
PaddleLayer
(
layer_id
,
kernel
,
inputs
,
outputs
,
scope_name
=
scope_name
,
**
kwargs
)
layer
=
PaddleLayer
(
layer_id
,
kernel
,
inputs
,
outputs
,
scope_name
=
scope_name
,
**
kwargs
)
self
.
layers
[
layer_id
]
=
layer
self
.
layers
[
layer_id
]
=
layer
if
layer
.
kernel
in
[
"prim.list_unpack"
or
"prim.tuple_unpack"
]:
self
.
has_unpack
=
True
return
layer_id
return
layer_id
def
del_layer
(
self
,
layer_id
):
def
del_layer
(
self
,
layer_id
):
...
@@ -272,12 +275,16 @@ class PaddleGraph(object):
...
@@ -272,12 +275,16 @@ class PaddleGraph(object):
def
gen_dygraph_model
(
self
,
save_dir
,
jit_type
=
None
):
def
gen_dygraph_model
(
self
,
save_dir
,
jit_type
=
None
):
if
jit_type
==
"trace"
:
if
jit_type
==
"trace"
:
if
not
self
.
has_unpack
:
from
x2paddle.optimizer.pytorch_code_optimizer
import
HierarchicalTree
from
x2paddle.optimizer.pytorch_code_optimizer
import
HierarchicalTree
hierarchical_tree
=
HierarchicalTree
(
self
)
hierarchical_tree
=
HierarchicalTree
(
self
)
for
layer_id
,
layer
in
self
.
layers
.
items
():
for
layer_id
,
layer
in
self
.
layers
.
items
():
hierarchical_tree
.
insert
(
layer
)
hierarchical_tree
.
insert
(
layer
)
hierarchical_tree
.
save_source_files
(
save_dir
)
hierarchical_tree
.
save_source_files
(
save_dir
)
self
.
dump_dygraph_parameter
(
save_dir
)
self
.
dump_dygraph_parameter
(
save_dir
)
else
:
self
.
gen_dygraph_code
(
save_dir
)
self
.
dump_dygraph_parameter
(
save_dir
)
else
:
else
:
if
self
.
source_type
==
"pytorch"
:
if
self
.
source_type
==
"pytorch"
:
from
x2paddle.optimizer.pytorch_code_optimizer
import
ModuleGraph
from
x2paddle.optimizer.pytorch_code_optimizer
import
ModuleGraph
...
...
x2paddle/op_mapper/dygraph/onnx2paddle/opset9/opset.py
浏览文件 @
8ec4883c
...
@@ -313,6 +313,9 @@ class OpSet9():
...
@@ -313,6 +313,9 @@ class OpSet9():
inputs
[
'size'
]
=
var_hw
inputs
[
'size'
]
=
var_hw
attrs
=
{
"align_corners"
:
False
,
attrs
=
{
"align_corners"
:
False
,
"mode"
:
string
(
node
.
get_attr
(
'mode'
,
'nearest'
))}
"mode"
:
string
(
node
.
get_attr
(
'mode'
,
'nearest'
))}
val_x_shape
=
val_x
.
out_shapes
[
0
]
if
len
(
val_x_shape
)
==
4
:
attrs
[
"mode"
]
=
string
(
"bilinear"
)
self
.
paddle_graph
.
add_layer
(
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.nn.functional.interpolate"
,
kernel
=
"paddle.nn.functional.interpolate"
,
inputs
=
inputs
,
inputs
=
inputs
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录