Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
eec84a0b
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看板
提交
eec84a0b
编写于
4月 29, 2022
作者:
W
wjj19950828
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/develop' into Support_HF_ops
上级
276a614d
aab6c75d
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
60 addition
and
5 deletion
+60
-5
docs/inference_model_convertor/op_list.md
docs/inference_model_convertor/op_list.md
+1
-1
x2paddle/op_mapper/pytorch2paddle/aten.py
x2paddle/op_mapper/pytorch2paddle/aten.py
+49
-0
x2paddle/optimizer/fusion/trace_fc_fuser.py
x2paddle/optimizer/fusion/trace_fc_fuser.py
+7
-4
x2paddle/optimizer/pattern_matcher.py
x2paddle/optimizer/pattern_matcher.py
+3
-0
未找到文件。
docs/inference_model_convertor/op_list.md
浏览文件 @
eec84a0b
...
@@ -114,7 +114,7 @@ Aten:
...
@@ -114,7 +114,7 @@ Aten:
| 117 | aten::bitwise
\_
not | 118 | aten::bitwise
\_
xor | 119 | aten::bitwise
\_
and | 120 | aten::silu |
| 117 | aten::bitwise
\_
not | 118 | aten::bitwise
\_
xor | 119 | aten::bitwise
\_
and | 120 | aten::silu |
| 121 | aten::repeat
\_
interleave | 122 | aten::maxpool1d | 123 | aten::frobenius
\_
norm | 124 | aten::format |
| 121 | aten::repeat
\_
interleave | 122 | aten::maxpool1d | 123 | aten::frobenius
\_
norm | 124 | aten::format |
| 125 | aten::complex | 126 | aten::real | 127 | aten::imag | 128 | aten::fft
\_
rfftn |
| 125 | aten::complex | 126 | aten::real | 127 | aten::imag | 128 | aten::fft
\_
rfftn |
| 129 | aten::fft
\_
irfftn | 130 | aten::hardsigmoid | 131 | aten::hardswish |
|
|
| 129 | aten::fft
\_
irfftn | 130 | aten::hardsigmoid | 131 | aten::hardswish |
132 | aten::linear
|
Prim:
Prim:
...
...
x2paddle/op_mapper/pytorch2paddle/aten.py
浏览文件 @
eec84a0b
...
@@ -3238,6 +3238,55 @@ def aten_len(mapper, graph, node):
...
@@ -3238,6 +3238,55 @@ def aten_len(mapper, graph, node):
return
current_inputs
,
current_outputs
return
current_inputs
,
current_outputs
def
aten_linear
(
mapper
,
graph
,
node
):
"""
TorchScript Code:
%x.6 : Float(1, 128, strides=[128, 1]) = aten::linear(%input.305, %weight.629, %bias.317)
Parameter meaning:
%x.6 (Tensor): output
%input.305 (Tensor): input tensor
%weight.629 (Tensor): weight tensor
%bias.317 (Tensor): bias tensor
"""
scope_name
=
mapper
.
normalize_scope_name
(
node
)
output_name
=
mapper
.
_get_outputs_name
(
node
)[
0
]
layer_outputs
=
[
output_name
]
layer_inputs
=
{}
layer_attrs
=
{}
inputs_name
,
inputs_node
=
mapper
.
_get_inputs_name
(
node
)
# outputs list
current_outputs
=
[
output_name
]
# inputs list
mapper
.
_check_input
(
graph
,
inputs_node
[
0
],
inputs_name
[
0
],
current_outputs
,
scope_name
)
layer_inputs
[
"x"
]
=
inputs_name
[
0
]
# transpose weight
mapper
.
_check_input
(
graph
,
inputs_node
[
1
],
inputs_name
[
1
],
current_outputs
,
scope_name
)
layer_attrs_transpose
=
{}
layer_attrs_transpose
[
"perm"
]
=
[
1
,
0
]
graph
.
add_layer
(
"paddle.transpose"
,
inputs
=
{
"x"
:
inputs_name
[
1
]},
outputs
=
[
inputs_name
[
1
]
+
"_transpose"
],
scope_name
=
scope_name
,
**
layer_attrs_transpose
)
layer_inputs
[
"weight"
]
=
inputs_name
[
1
]
+
"_transpose"
if
len
(
inputs_name
)
==
3
:
mapper
.
_check_input
(
graph
,
inputs_node
[
2
],
inputs_name
[
2
],
current_outputs
,
scope_name
)
layer_inputs
[
"bias"
]
=
inputs_name
[
2
]
current_inputs
=
list
(
layer_inputs
.
values
())
graph
.
add_layer
(
"paddle.nn.functional.linear"
,
inputs
=
layer_inputs
,
outputs
=
layer_outputs
,
scope_name
=
scope_name
,
**
layer_attrs
)
return
current_inputs
,
current_outputs
def
aten_log
(
mapper
,
graph
,
node
):
def
aten_log
(
mapper
,
graph
,
node
):
""" 构构造log的PaddleLayer。
""" 构构造log的PaddleLayer。
TorchScript示例:
TorchScript示例:
...
...
x2paddle/optimizer/fusion/trace_fc_fuser.py
浏览文件 @
eec84a0b
...
@@ -113,10 +113,13 @@ class TraceFcFuser(FuseBase):
...
@@ -113,10 +113,13 @@ class TraceFcFuser(FuseBase):
attrs
[
"out_features"
]
=
parameters
[
weight_name
].
shape
[
0
]
attrs
[
"out_features"
]
=
parameters
[
weight_name
].
shape
[
0
]
linear_name
=
"linear{}"
.
format
(
self
.
linear_index
)
linear_name
=
"linear{}"
.
format
(
self
.
linear_index
)
self
.
linear_index
+=
1
self
.
linear_index
+=
1
parameters
[
"{}.weight"
.
format
(
linear_name
)]
=
parameters
[
weight_numpy
=
parameters
[
weight_name
]
weight_name
].
transpose
((
1
,
0
))
parameters
[
"{}.weight"
.
format
(
linear_name
)]
=
weight_numpy
.
transpose
(
parameters
[
"{}.bias"
.
format
(
linear_name
)]
=
np
.
squeeze
(
parameters
[
(
1
,
0
))
bias_name
])
self
.
rm_params
.
add
(
weight_name
)
bias_numpy
=
parameters
[
bias_name
]
parameters
[
"{}.bias"
.
format
(
linear_name
)]
=
np
.
squeeze
(
bias_numpy
)
self
.
rm_params
.
add
(
bias_name
)
new_layer
=
PaddleLayer
(
new_layer
=
PaddleLayer
(
layers_id
[
0
],
layers_id
[
0
],
"paddle.nn.Linear"
,
"paddle.nn.Linear"
,
...
...
x2paddle/optimizer/pattern_matcher.py
浏览文件 @
eec84a0b
...
@@ -325,6 +325,7 @@ class FuseBase(object):
...
@@ -325,6 +325,7 @@ class FuseBase(object):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
pattern
=
PaddleGraph
()
self
.
pattern
=
PaddleGraph
()
self
.
patterns
=
list
()
self
.
patterns
=
list
()
self
.
rm_params
=
set
()
def
operate
(
self
,
graph
,
match_kind
=
"topo"
):
def
operate
(
self
,
graph
,
match_kind
=
"topo"
):
parameters
=
graph
.
parameters
parameters
=
graph
.
parameters
...
@@ -335,6 +336,8 @@ class FuseBase(object):
...
@@ -335,6 +336,8 @@ class FuseBase(object):
subgraph
=
get_subgraph
(
""
,
first_layer_id
,
graph
)
subgraph
=
get_subgraph
(
""
,
first_layer_id
,
graph
)
self
.
insert_new_layer
(
subgraph
,
parameters
,
match
)
self
.
insert_new_layer
(
subgraph
,
parameters
,
match
)
self
.
delete_match
(
graph
)
self
.
delete_match
(
graph
)
for
param_name
in
self
.
rm_params
:
parameters
.
pop
(
param_name
)
graph
.
build
()
graph
.
build
()
def
perform_pattern_matcher
(
self
,
graph
,
match_kind
=
"topo"
):
def
perform_pattern_matcher
(
self
,
graph
,
match_kind
=
"topo"
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录