Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7a4c29e0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
7a4c29e0
编写于
2月 20, 2020
作者:
W
wangchaochaohu
提交者:
GitHub
2月 20, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add fuse_group python unitest (#22532)
* add fuse_group python unintest
上级
405bb94b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
113 addition
and
0 deletion
+113
-0
python/paddle/fluid/tests/unittests/ir/CMakeLists.txt
python/paddle/fluid/tests/unittests/ir/CMakeLists.txt
+4
-0
python/paddle/fluid/tests/unittests/ir/test_ir_fusion_group.py
...n/paddle/fluid/tests/unittests/ir/test_ir_fusion_group.py
+109
-0
未找到文件。
python/paddle/fluid/tests/unittests/ir/CMakeLists.txt
浏览文件 @
7a4c29e0
file
(
GLOB TEST_IR_PASSES RELATIVE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"test_*.py"
)
file
(
GLOB TEST_IR_PASSES RELATIVE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
"test_*.py"
)
string
(
REPLACE
".py"
""
TEST_IR_PASSES
"
${
TEST_IR_PASSES
}
"
)
string
(
REPLACE
".py"
""
TEST_IR_PASSES
"
${
TEST_IR_PASSES
}
"
)
if
(
NOT WITH_GPU OR WIN32 OR APPLE
)
LIST
(
REMOVE_ITEM TEST_IR_PASSES test_ir_fusion_group
)
endif
()
foreach
(
target
${
TEST_IR_PASSES
}
)
foreach
(
target
${
TEST_IR_PASSES
}
)
py_test_modules
(
${
target
}
MODULES
${
target
}
)
py_test_modules
(
${
target
}
MODULES
${
target
}
)
endforeach
()
endforeach
()
...
...
python/paddle/fluid/tests/unittests/ir/test_ir_fusion_group.py
0 → 100644
浏览文件 @
7a4c29e0
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
unittest
import
numpy
as
np
from
pass_test
import
PassTest
import
paddle.fluid
as
fluid
import
paddle.fluid.core
as
core
class
FusionGroupPassTest
(
PassTest
):
def
setUp
(
self
):
with
fluid
.
program_guard
(
self
.
main_program
,
self
.
startup_program
):
data1
=
fluid
.
data
(
name
=
"data1"
,
shape
=
[
32
,
128
],
dtype
=
"float32"
)
data2
=
fluid
.
data
(
name
=
"data2"
,
shape
=
[
32
,
128
],
dtype
=
"float32"
)
data3
=
fluid
.
data
(
name
=
"data3"
,
shape
=
[
32
,
128
],
dtype
=
"float32"
)
tmp_1
=
fluid
.
layers
.
elementwise_add
(
data1
,
data2
)
tmp_2
=
fluid
.
layers
.
elementwise_mul
(
data3
,
tmp_1
)
self
.
feeds
=
{
"data1"
:
np
.
random
.
random
((
32
,
128
)).
astype
(
"float32"
),
"data2"
:
np
.
random
.
random
((
32
,
128
)).
astype
(
"float32"
),
"data3"
:
np
.
random
.
random
((
32
,
128
)).
astype
(
"float32"
)
}
self
.
fetch_list
=
[
tmp_1
,
tmp_2
]
self
.
pass_names
=
"fusion_group_pass"
self
.
fused_op_type
=
"fusion_group"
self
.
num_fused_ops
=
1
def
test_check_output
(
self
):
use_gpu_set
=
[]
if
core
.
is_compiled_with_cuda
():
use_gpu_set
.
append
(
True
)
for
use_gpu
in
use_gpu_set
:
self
.
pass_attrs
=
{
"fusion_group_pass"
:
{
"use_gpu"
:
use_gpu
}}
place
=
fluid
.
CUDAPlace
(
0
)
if
use_gpu
else
fluid
.
CPUPlace
()
self
.
check_output_with_place
(
place
,
startup_on_cpu
=
False
)
class
FusionGroupPassTest1
(
FusionGroupPassTest
):
def
setUp
(
self
):
with
fluid
.
program_guard
(
self
.
main_program
,
self
.
startup_program
):
data
=
[]
for
i
in
range
(
5
):
data
.
append
(
fluid
.
data
(
name
=
(
"data"
+
str
(
i
)),
shape
=
[
32
,
128
],
dtype
=
"float32"
))
tmp_1
=
(
fluid
.
layers
.
assign
(
data
[
0
])
*
fluid
.
layers
.
sigmoid
(
data
[
1
])
)
+
(
fluid
.
layers
.
sigmoid
(
data
[
2
])
*
fluid
.
layers
.
tanh
(
data
[
3
]))
tmp_2
=
fluid
.
layers
.
tanh
(
tmp_1
)
+
fluid
.
layers
.
sigmoid
(
data
[
4
])
self
.
feeds
=
{}
for
i
in
range
(
5
):
self
.
feeds
[
"data"
+
str
(
i
)]
=
np
.
random
.
random
(
(
32
,
128
)).
astype
(
"float32"
)
self
.
fetch_list
=
[
tmp_1
,
tmp_2
]
self
.
pass_names
=
"fusion_group_pass"
self
.
fused_op_type
=
"fusion_group"
self
.
num_fused_ops
=
1
class
FusionGroupPassTest2
(
FusionGroupPassTest
):
def
setUp
(
self
):
with
fluid
.
program_guard
(
self
.
main_program
,
self
.
startup_program
):
data
=
[]
for
i
in
range
(
3
):
data
.
append
(
fluid
.
data
(
name
=
(
"data"
+
str
(
i
)),
shape
=
[
32
,
128
],
dtype
=
"float32"
))
data
.
append
(
fluid
.
data
(
name
=
"data3"
,
shape
=
[
128
,
32
],
dtype
=
"float32"
))
tmp_1
=
fluid
.
layers
.
relu
((
data
[
0
]
-
data
[
1
])
*
data
[
2
])
tmp_2
=
fluid
.
layers
.
sigmoid
(
data
[
3
])
tmp_3
=
fluid
.
layers
.
relu
(
tmp_2
)
tmp_4
=
fluid
.
layers
.
mul
(
tmp_1
,
tmp_3
)
self
.
feeds
=
{}
for
i
in
range
(
3
):
self
.
feeds
[
"data"
+
str
(
i
)]
=
np
.
random
.
random
(
(
32
,
128
)).
astype
(
"float32"
)
self
.
feeds
[
"data3"
]
=
np
.
random
.
random
((
128
,
32
)).
astype
(
"float32"
)
self
.
fetch_list
=
[
tmp_1
,
tmp_2
,
tmp_3
,
tmp_4
]
self
.
pass_names
=
"fusion_group_pass"
self
.
fused_op_type
=
"fusion_group"
self
.
num_fused_ops
=
2
if
__name__
==
"__main__"
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录