Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
b5281541
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看板
提交
b5281541
编写于
11月 23, 2020
作者:
S
SunAhong1993
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify caffe
上级
3dad710a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
19 deletion
+11
-19
x2paddle/core/program.py
x2paddle/core/program.py
+2
-1
x2paddle/op_mapper/dygraph/caffe2paddle/caffe_op_mapper.py
x2paddle/op_mapper/dygraph/caffe2paddle/caffe_op_mapper.py
+9
-18
未找到文件。
x2paddle/core/program.py
浏览文件 @
b5281541
...
...
@@ -526,7 +526,8 @@ class PaddleGraph(object):
for
layer_id
,
layer
in
self
.
layers
.
items
():
if
(
"paddle.nn"
in
layer
.
kernel
and
"functional"
not
in
layer
.
kernel
)
or
layer
.
kernel
==
"paddle.to_tensor"
or
\
layer
.
kernel
.
startswith
(
"custom_layer"
):
layer
.
kernel
.
startswith
(
"custom_layer"
)
or
\
layer
.
kernel
.
startswith
(
"paddle.fluid.dygraph"
):
line
=
"{}"
.
format
(
layer
.
outputs
[
0
]
)
if
layer
.
kernel
==
"paddle.to_tensor"
and
not
layer
.
attrs
[
...
...
x2paddle/op_mapper/dygraph/caffe2paddle/caffe_op_mapper.py
浏览文件 @
b5281541
...
...
@@ -527,20 +527,16 @@ class CaffeOpMapper(OpMapper):
assert
len
(
node
.
inputs
)
>=
1
,
"The count of Concat node
\'
s input is not more than 1."
inputs_
dic
t
=
dict
()
inputs_
lis
t
=
dict
()
for
i
in
range
(
len
(
node
.
inputs
)):
input
=
self
.
graph
.
get_bottom_node
(
node
,
idx
=
i
,
copy
=
True
)
inputs_
dict
[
"input{}"
.
format
(
i
)
]
=
self
.
get_input_name
(
input
)
inputs_
list
[
i
]
=
self
.
get_input_name
(
input
)
params
=
node
.
layer
.
concat_param
axis
=
params
.
axis
layer_attrs
=
{
'axis'
:
axis
}
self
.
paddle_graph
.
add_layer
(
"prim.list"
,
inputs
=
inputs_dict
,
outputs
=
[
node
.
layer_name
+
"_list"
])
self
.
paddle_graph
.
add_layer
(
"paddle.concat"
,
inputs
=
{
"x"
:
node
.
layer_name
+
"_list"
},
inputs
=
{
"x"
:
inputs_list
},
outputs
=
[
node
.
layer_name
],
**
layer_attrs
)
...
...
@@ -616,15 +612,15 @@ class CaffeOpMapper(OpMapper):
if
hasattr
(
params
,
'coeff'
)
and
len
(
params
.
coeff
)
==
2
:
coeff
=
params
.
coeff
self
.
paddle_graph
.
add_layer
(
"p
rim.mul
"
,
"p
addle.scale
"
,
inputs
=
{
"x"
:
input0_name
},
outputs
=
[
node
.
layer_name
+
'_mul0'
],
y
=
coeff
[
0
])
scale
=
coeff
[
0
])
self
.
paddle_graph
.
add_layer
(
"p
rim.mul
"
,
"p
addle.scale
"
,
inputs
=
{
"x"
:
input1_name
},
outputs
=
[
node
.
layer_name
+
'_mul1'
],
y
=
coeff
[
2
])
scale
=
coeff
[
2
])
inputs_dict
=
{}
inputs_dict
[
'x'
]
=
node
.
layer_name
+
'_mul0'
inputs_dict
[
'y'
]
=
node
.
layer_name
+
'_mul1'
...
...
@@ -760,7 +756,7 @@ class CaffeOpMapper(OpMapper):
param2_shape
=
self
.
params
[
node
.
layer_name
+
"_cparam2"
].
shape
param2_shape_len
=
len
(
param2_shape
)
diff_len
=
len
(
output_shape
)
-
axis
-
param2_shape_len
new_shape
=
param2_shape
+
[
1
]
*
diff_len
new_shape
=
list
(
param2_shape
)
+
[
1
]
*
diff_len
self
.
paddle_graph
.
add_layer
(
"paddle.reshape"
,
inputs
=
{
"x"
:
node
.
layer_name
+
"_cparam2"
},
...
...
@@ -805,14 +801,9 @@ class CaffeOpMapper(OpMapper):
inputs
=
{
"x"
:
node
.
layer_name
+
"_index_var"
},
outputs
=
[
node
.
layer_name
+
"_index_var"
],
dtype
=
"{}_topk_var.dtype"
.
format
(
node
.
layer_name
))
self
.
paddle_graph
.
add_layer
(
"prim.list"
,
inputs
=
{
"input0"
:
node
.
layer_name
+
"_topk_var"
,
"input1"
:
node
.
layer_name
+
"_index_var"
},
outputs
=
[
node
.
layer_name
+
"_list"
])
self
.
paddle_graph
.
add_layer
(
"paddle.concat"
,
inputs
=
{
"x"
:
node
.
layer_name
+
"_list"
},
inputs
=
{
"x"
:
[
node
.
layer_name
+
"_topk_var"
,
node
.
layer_name
+
"_index_var"
]
},
outputs
=
[
node
.
layer_name
],
axis
=
axis
)
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录