Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
c95adaf5
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看板
未验证
提交
c95adaf5
编写于
1月 18, 2022
作者:
J
Jason
提交者:
GitHub
1月 18, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #729 from wjj19950828/Add_Fourier_transform
Add fourier transform ops
上级
99e2ea67
a8e794ca
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
180 addition
and
0 deletion
+180
-0
docs/inference_model_convertor/op_list.md
docs/inference_model_convertor/op_list.md
+3
-0
x2paddle/op_mapper/pytorch2paddle/aten.py
x2paddle/op_mapper/pytorch2paddle/aten.py
+177
-0
未找到文件。
docs/inference_model_convertor/op_list.md
浏览文件 @
c95adaf5
...
...
@@ -113,6 +113,9 @@ Aten:
| 113 | aten::upsample
\_
nearest2d | 114 | aten::split
\_
with
\_
sizes | 115 | aten::sum | 116 | aten::instance
\_
norm |
| 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 |
| 125 | aten::complex | 126 | aten::real | 127 | aten::imag | 128 | aten::fft
\_
rfftn |
| 129 | aten::fft
\_
irfftn | | | | | | |
Prim:
| 序号 | OP | 序号 | OP | 序号 | OP | 序号 | OP |
...
...
x2paddle/op_mapper/pytorch2paddle/aten.py
浏览文件 @
c95adaf5
...
...
@@ -1038,6 +1038,43 @@ def aten_clamp_min(mapper, graph, node):
return
current_inputs
,
current_outputs
def
aten_complex
(
mapper
,
graph
,
node
):
"""
TorchScript示例:
%ret.2 : Tensor = aten::complex(%150, %156)
参数含义:
%ret.2 (Tensor): complex结果Tensor。
%150 (Tensor): 实部输入Tensor。
%156 (Tensor): 虚部输入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
)
# 获取当前节点输出的list
current_outputs
=
[
output_name
]
# 处理输入0,即%150
mapper
.
_check_input
(
graph
,
inputs_node
[
0
],
inputs_name
[
0
],
current_outputs
,
scope_name
)
layer_inputs
[
"real"
]
=
inputs_name
[
0
]
# 处理输入1,即%156
mapper
.
_check_input
(
graph
,
inputs_node
[
1
],
inputs_name
[
1
],
current_outputs
,
scope_name
)
layer_inputs
[
"imag"
]
=
inputs_name
[
1
]
# 获取当前节点输入的list
current_inputs
=
list
(
layer_inputs
.
values
())
graph
.
add_layer
(
"paddle.complex"
,
inputs
=
layer_inputs
,
outputs
=
layer_outputs
,
scope_name
=
scope_name
,
**
layer_attrs
)
return
current_inputs
,
current_outputs
def
aten___contains__
(
mapper
,
graph
,
node
):
""" 构造in的PaddleLayer。
TorchScript示例:
...
...
@@ -2070,6 +2107,86 @@ def aten_feature_dropout(mapper, graph, node):
return
current_inputs
,
current_outputs
def
aten_fft_rfftn
(
mapper
,
graph
,
node
):
"""
TorchScript示例:
%x_gap.15 : Tensor = aten::fft_rfftn(%x.58, %2166, %1450, %1453)
参数含义:
%x_gap.15 (Tensor): Output Tensor。
%x.58 (Tensor): Input Tensor。
%2166:Sequence Length
%1450:axes
%1453:norm mode
"""
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
)
# 获取当前节点输出的list
current_outputs
=
[
output_name
]
# 处理输入0,即%n.3
mapper
.
_check_input
(
graph
,
inputs_node
[
0
],
inputs_name
[
0
],
current_outputs
,
scope_name
)
layer_inputs
[
"x"
]
=
inputs_name
[
0
]
# 获取当前节点输入的list
current_inputs
=
list
(
layer_inputs
.
values
())
if
inputs_name
[
1
]
in
mapper
.
attrs
:
layer_attrs
[
"s"
]
=
mapper
.
attrs
[
inputs_name
[
1
]]
if
inputs_name
[
2
]
in
mapper
.
attrs
:
layer_attrs
[
"axes"
]
=
mapper
.
attrs
[
inputs_name
[
2
]]
if
inputs_name
[
3
]
in
mapper
.
attrs
:
layer_attrs
[
"norm"
]
=
mapper
.
attrs
[
inputs_name
[
3
]]
graph
.
add_layer
(
"paddle.fft.rfftn"
,
inputs
=
layer_inputs
,
outputs
=
layer_outputs
,
scope_name
=
scope_name
,
**
layer_attrs
)
return
current_inputs
,
current_outputs
def
aten_fft_irfftn
(
mapper
,
graph
,
node
):
"""
TorchScript示例:
%x_gap.15 : Tensor = aten::fft_irfftn(%x.58, %2166, %1450, %1453)
参数含义:
%x_gap.15 (Tensor): Output Tensor。
%x.58 (Tensor): Input Tensor。
%2166:Sequence Length
%1450:axes
%1453:norm mode
"""
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
)
# 获取当前节点输出的list
current_outputs
=
[
output_name
]
# 处理输入0,即%n.3
mapper
.
_check_input
(
graph
,
inputs_node
[
0
],
inputs_name
[
0
],
current_outputs
,
scope_name
)
layer_inputs
[
"x"
]
=
inputs_name
[
0
]
# 获取当前节点输入的list
current_inputs
=
list
(
layer_inputs
.
values
())
if
inputs_name
[
1
]
in
mapper
.
attrs
:
layer_attrs
[
"s"
]
=
mapper
.
attrs
[
inputs_name
[
1
]]
if
inputs_name
[
2
]
in
mapper
.
attrs
:
layer_attrs
[
"axes"
]
=
mapper
.
attrs
[
inputs_name
[
2
]]
if
inputs_name
[
3
]
in
mapper
.
attrs
:
layer_attrs
[
"norm"
]
=
mapper
.
attrs
[
inputs_name
[
3
]]
graph
.
add_layer
(
"paddle.fft.irfftn"
,
inputs
=
layer_inputs
,
outputs
=
layer_outputs
,
scope_name
=
scope_name
,
**
layer_attrs
)
return
current_inputs
,
current_outputs
def
aten_flatten
(
mapper
,
graph
,
node
):
""" 构造flatten的PaddleLayer。
TorchScript示例:
...
...
@@ -2669,6 +2786,36 @@ def aten_index(mapper, graph, node):
return
current_inputs
,
current_outputs
def
aten_imag
(
mapper
,
graph
,
node
):
""" 构造获取绝对值的PaddleLayer。
TorchScript示例:
%n0.3 : Tensor = aten::imag(%1)
参数含义:
%1 (Tensor): Complex Tensor。
%n0.3 (Tensor): 返回虚部 Tensor。
"""
scope_name
=
mapper
.
normalize_scope_name
(
node
)
output_name
=
mapper
.
_get_outputs_name
(
node
)[
0
]
layer_outputs
=
[
output_name
]
layer_inputs
=
{}
inputs_name
,
inputs_node
=
mapper
.
_get_inputs_name
(
node
)
# 获取当前节点输出的list
current_outputs
=
[
output_name
]
# 处理输入0,即%n.3
mapper
.
_check_input
(
graph
,
inputs_node
[
0
],
inputs_name
[
0
],
current_outputs
,
scope_name
)
layer_inputs
[
"x"
]
=
inputs_name
[
0
]
# 获取当前节点输入的list
current_inputs
=
list
(
layer_inputs
.
values
())
graph
.
add_layer
(
"paddle.imag"
,
inputs
=
layer_inputs
,
outputs
=
layer_outputs
,
scope_name
=
scope_name
)
return
current_inputs
,
current_outputs
def
aten_index_select
(
mapper
,
graph
,
node
):
""" 构造选择元素的PaddleLayer。
TorchScript示例:
...
...
@@ -4068,6 +4215,36 @@ def aten_prelu(mapper, graph, node):
return
current_inputs
,
current_outputs
def
aten_real
(
mapper
,
graph
,
node
):
"""
TorchScript示例:
%n0.3 : Tensor = aten::real(%n.3)
参数含义:
%n0.3 (Tensor): Return Real Tensor。
%n.3 (Tensor): Input Complex Tensor。
"""
scope_name
=
mapper
.
normalize_scope_name
(
node
)
output_name
=
mapper
.
_get_outputs_name
(
node
)[
0
]
layer_outputs
=
[
output_name
]
layer_inputs
=
{}
inputs_name
,
inputs_node
=
mapper
.
_get_inputs_name
(
node
)
# 获取当前节点输出的list
current_outputs
=
[
output_name
]
# 处理输入0,即%n.3
mapper
.
_check_input
(
graph
,
inputs_node
[
0
],
inputs_name
[
0
],
current_outputs
,
scope_name
)
layer_inputs
[
"x"
]
=
inputs_name
[
0
]
# 获取当前节点输入的list
current_inputs
=
list
(
layer_inputs
.
values
())
graph
.
add_layer
(
"paddle.real"
,
inputs
=
layer_inputs
,
outputs
=
layer_outputs
,
scope_name
=
scope_name
)
return
current_inputs
,
current_outputs
def
aten_reflection_pad1d
(
mapper
,
graph
,
node
):
""" 构造1维映射填充的PaddleLayer。
TorchScript示例:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录