Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b0d1ac16
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b0d1ac16
编写于
11月 26, 2020
作者:
J
joanna.wozna.intel
提交者:
GitHub
11月 26, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add bf16 pool2d and unify bf16 unit tests (#29039)
* Add bf16 pool2d and unify bf16 unit tests * Add change default ops test
上级
fddea674
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
114 addition
and
7 deletion
+114
-7
paddle/fluid/framework/ir/graph_pattern_detector.cc
paddle/fluid/framework/ir/graph_pattern_detector.cc
+2
-2
paddle/fluid/framework/ir/mkldnn/cpu_bfloat16_placement_pass_tester.cc
...framework/ir/mkldnn/cpu_bfloat16_placement_pass_tester.cc
+1
-1
paddle/fluid/operators/mkldnn/pool_mkldnn_op.cc
paddle/fluid/operators/mkldnn/pool_mkldnn_op.cc
+2
-1
python/paddle/fluid/tests/unittests/mkldnn/test_concat_bf16_mkldnn_op.py
...luid/tests/unittests/mkldnn/test_concat_bf16_mkldnn_op.py
+1
-1
python/paddle/fluid/tests/unittests/mkldnn/test_pool2d_bf16_mkldnn_op.py
...luid/tests/unittests/mkldnn/test_pool2d_bf16_mkldnn_op.py
+100
-0
python/paddle/fluid/tests/unittests/mkldnn/test_reshape_bf16_op.py
...ddle/fluid/tests/unittests/mkldnn/test_reshape_bf16_op.py
+1
-1
python/paddle/fluid/tests/unittests/mkldnn/test_softmax_bf16_mkldnn_op.py
...uid/tests/unittests/mkldnn/test_softmax_bf16_mkldnn_op.py
+2
-0
python/paddle/fluid/tests/unittests/mkldnn/test_transpose_bf16_mkldnn_op.py
...d/tests/unittests/mkldnn/test_transpose_bf16_mkldnn_op.py
+1
-1
tools/static_mode_white_list.py
tools/static_mode_white_list.py
+4
-0
未找到文件。
paddle/fluid/framework/ir/graph_pattern_detector.cc
浏览文件 @
b0d1ac16
...
@@ -2103,8 +2103,8 @@ PDNode *patterns::Bfloat16Placement::operator()(
...
@@ -2103,8 +2103,8 @@ PDNode *patterns::Bfloat16Placement::operator()(
std
::
unordered_set
<
std
::
string
>
supported_op_types
=
std
::
unordered_set
<
std
::
string
>
supported_op_types
=
std
::
unordered_set
<
std
::
string
>
(
std
::
unordered_set
<
std
::
string
>
(
{
"concat"
,
"conv2d"
,
"elementwise_add"
,
"elementwise_mul"
,
"fc"
,
{
"concat"
,
"conv2d"
,
"elementwise_add"
,
"elementwise_mul"
,
"fc"
,
"fusion_gru"
,
"gelu"
,
"layer_norm"
,
"matmul"
,
"
reshape2"
,
"softmax
"
,
"fusion_gru"
,
"gelu"
,
"layer_norm"
,
"matmul"
,
"
pool2d"
,
"reshape2
"
,
"sum"
,
"transpose2"
});
"s
oftmax"
,
"s
um"
,
"transpose2"
});
if
(
!
bfloat16_enabled_op_types
.
empty
())
{
if
(
!
bfloat16_enabled_op_types
.
empty
())
{
supported_op_types
=
bfloat16_enabled_op_types
;
supported_op_types
=
bfloat16_enabled_op_types
;
}
}
...
...
paddle/fluid/framework/ir/mkldnn/cpu_bfloat16_placement_pass_tester.cc
浏览文件 @
b0d1ac16
...
@@ -136,7 +136,7 @@ TEST(Bfloat16PlacementPass, enabled_conv_and_pool) {
...
@@ -136,7 +136,7 @@ TEST(Bfloat16PlacementPass, enabled_conv_and_pool) {
MainTest
({
"conv2d"
,
"pool2d"
},
3
);
MainTest
({
"conv2d"
,
"pool2d"
},
3
);
}
}
TEST
(
Bfloat16PlacementPass
,
default_attr_value
)
{
DefaultAttrTest
(
7
);
}
TEST
(
Bfloat16PlacementPass
,
default_attr_value
)
{
DefaultAttrTest
(
10
);
}
}
// namespace ir
}
// namespace ir
}
// namespace framework
}
// namespace framework
...
...
paddle/fluid/operators/mkldnn/pool_mkldnn_op.cc
浏览文件 @
b0d1ac16
...
@@ -181,7 +181,8 @@ namespace ops = paddle::operators;
...
@@ -181,7 +181,8 @@ namespace ops = paddle::operators;
REGISTER_OP_KERNEL
(
pool2d
,
MKLDNN
,
::
paddle
::
platform
::
CPUPlace
,
REGISTER_OP_KERNEL
(
pool2d
,
MKLDNN
,
::
paddle
::
platform
::
CPUPlace
,
ops
::
PoolMKLDNNOpKernel
<
float
>
,
ops
::
PoolMKLDNNOpKernel
<
float
>
,
ops
::
PoolMKLDNNOpKernel
<
int8_t
>
,
ops
::
PoolMKLDNNOpKernel
<
int8_t
>
,
ops
::
PoolMKLDNNOpKernel
<
uint8_t
>
);
ops
::
PoolMKLDNNOpKernel
<
uint8_t
>
,
ops
::
PoolMKLDNNOpKernel
<
paddle
::
platform
::
bfloat16
>
);
REGISTER_OP_KERNEL
(
pool2d_grad
,
MKLDNN
,
::
paddle
::
platform
::
CPUPlace
,
REGISTER_OP_KERNEL
(
pool2d_grad
,
MKLDNN
,
::
paddle
::
platform
::
CPUPlace
,
ops
::
PoolMKLDNNGradOpKernel
<
float
>
);
ops
::
PoolMKLDNNGradOpKernel
<
float
>
);
python/paddle/fluid/tests/unittests/mkldnn/test_concat_bf16_mkldnn_op.py
浏览文件 @
b0d1ac16
...
@@ -27,7 +27,6 @@ from paddle import enable_static
...
@@ -27,7 +27,6 @@ from paddle import enable_static
"place does not support BF16 evaluation"
)
"place does not support BF16 evaluation"
)
class
TestConcatBf16Op
(
OpTest
):
class
TestConcatBf16Op
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
enable_static
()
self
.
op_type
=
"concat"
self
.
op_type
=
"concat"
self
.
use_mkldnn
=
True
self
.
use_mkldnn
=
True
self
.
mkldnn_data_type
=
"bfloat16"
self
.
mkldnn_data_type
=
"bfloat16"
...
@@ -107,4 +106,5 @@ class TestAxis3Case(TestConcatBf16Op):
...
@@ -107,4 +106,5 @@ class TestAxis3Case(TestConcatBf16Op):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
enable_static
()
unittest
.
main
()
unittest
.
main
()
python/paddle/fluid/tests/unittests/mkldnn/test_pool2d_bf16_mkldnn_op.py
0 → 100644
浏览文件 @
b0d1ac16
# 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.
from
__future__
import
print_function
import
unittest
import
os
import
numpy
as
np
import
paddle.fluid.core
as
core
from
paddle.fluid.tests.unittests.op_test
import
OpTest
,
skip_check_grad_ci
,
convert_float_to_uint16
from
paddle.fluid.tests.unittests.test_pool2d_op
import
TestPool2D_Op
,
avg_pool2D_forward_naive
,
max_pool2D_forward_naive
from
paddle
import
enable_static
@
unittest
.
skipIf
(
not
core
.
supports_bfloat16
(),
"place does not support BF16 evaluation"
)
class
TestPoolBf16MklDNNOp
(
TestPool2D_Op
):
def
init_kernel_type
(
self
):
self
.
use_mkldnn
=
True
def
setUp
(
self
):
TestPool2D_Op
.
setUp
(
self
)
self
.
dtype
=
np
.
uint16
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
np
.
float32
)
output
=
(
self
.
pool2D_forward_naive
(
input
,
self
.
ksize
,
self
.
strides
,
self
.
paddings
,
self
.
global_pool
,
self
.
ceil_mode
,
self
.
exclusive
,
self
.
adaptive
,
"float32"
)).
astype
(
np
.
float32
)
self
.
inputs
=
{
'X'
:
convert_float_to_uint16
(
input
)}
self
.
outputs
=
{
'Out'
:
convert_float_to_uint16
(
output
)}
def
test_check_output
(
self
):
self
.
check_output_with_place
(
core
.
CPUPlace
())
def
test_check_grad
(
self
):
pass
class
TestCase1Avg
(
TestPoolBf16MklDNNOp
):
def
init_test_case
(
self
):
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
0
,
0
]
def
init_global_pool
(
self
):
self
.
global_pool
=
False
def
init_exclusive
(
self
):
self
.
exclusive
=
True
class
TestCase2Avg
(
TestPoolBf16MklDNNOp
):
def
init_test_case
(
self
):
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
1
,
1
]
def
init_global_pool
(
self
):
self
.
global_pool
=
False
def
init_exclusive
(
self
):
self
.
exclusive
=
False
class
TestCase0Max
(
TestPoolBf16MklDNNOp
):
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
class
TestCase1Max
(
TestCase1Avg
):
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
class
TestCase2Max
(
TestCase2Avg
):
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
if
__name__
==
"__main__"
:
enable_static
()
unittest
.
main
()
python/paddle/fluid/tests/unittests/mkldnn/test_reshape_bf16_op.py
浏览文件 @
b0d1ac16
...
@@ -27,7 +27,6 @@ from paddle import enable_static
...
@@ -27,7 +27,6 @@ from paddle import enable_static
"place does not support BF16 evaluation"
)
"place does not support BF16 evaluation"
)
class
TestReshapeBf16Op
(
OpTest
):
class
TestReshapeBf16Op
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
enable_static
()
self
.
op_type
=
"reshape2"
self
.
op_type
=
"reshape2"
self
.
use_mkldnn
=
True
self
.
use_mkldnn
=
True
self
.
mkldnn_data_type
=
"bfloat16"
self
.
mkldnn_data_type
=
"bfloat16"
...
@@ -59,4 +58,5 @@ class TestReshapeBf16Op(OpTest):
...
@@ -59,4 +58,5 @@ class TestReshapeBf16Op(OpTest):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
enable_static
()
unittest
.
main
()
unittest
.
main
()
python/paddle/fluid/tests/unittests/mkldnn/test_softmax_bf16_mkldnn_op.py
浏览文件 @
b0d1ac16
...
@@ -29,6 +29,8 @@ def stable_softmax(x):
...
@@ -29,6 +29,8 @@ def stable_softmax(x):
return
exps
/
np
.
sum
(
exps
)
return
exps
/
np
.
sum
(
exps
)
@
unittest
.
skipIf
(
not
core
.
supports_bfloat16
(),
"place does not support BF16 evaluation"
)
class
TestSoftmaxMKLDNNOp
(
TestSoftmaxOp
):
class
TestSoftmaxMKLDNNOp
(
TestSoftmaxOp
):
def
get_x_shape
(
self
):
def
get_x_shape
(
self
):
return
[
10
,
10
]
return
[
10
,
10
]
...
...
python/paddle/fluid/tests/unittests/mkldnn/test_transpose_bf16_mkldnn_op.py
浏览文件 @
b0d1ac16
...
@@ -25,7 +25,6 @@ from paddle import enable_static
...
@@ -25,7 +25,6 @@ from paddle import enable_static
"place does not support BF16 evaluation"
)
"place does not support BF16 evaluation"
)
class
TestTransposeOp
(
OpTest
):
class
TestTransposeOp
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
enable_static
()
self
.
op_type
=
"transpose2"
self
.
op_type
=
"transpose2"
self
.
use_mkldnn
=
True
self
.
use_mkldnn
=
True
self
.
mkldnn_data_type
=
"bfloat16"
self
.
mkldnn_data_type
=
"bfloat16"
...
@@ -63,4 +62,5 @@ class TestBF16Case(TestTransposeOp):
...
@@ -63,4 +62,5 @@ class TestBF16Case(TestTransposeOp):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
enable_static
()
unittest
.
main
()
unittest
.
main
()
tools/static_mode_white_list.py
浏览文件 @
b0d1ac16
...
@@ -425,6 +425,7 @@ STATIC_MODE_TESTING_LIST = [
...
@@ -425,6 +425,7 @@ STATIC_MODE_TESTING_LIST = [
'test_regularizer_api'
,
'test_regularizer_api'
,
'test_reorder_lod_tensor'
,
'test_reorder_lod_tensor'
,
'test_reshape_op'
,
'test_reshape_op'
,
'test_reshape_bf16_op'
,
'test_retinanet_detection_output'
,
'test_retinanet_detection_output'
,
'test_reverse_op'
,
'test_reverse_op'
,
'test_rmsprop_op'
,
'test_rmsprop_op'
,
...
@@ -582,6 +583,7 @@ STATIC_MODE_TESTING_LIST = [
...
@@ -582,6 +583,7 @@ STATIC_MODE_TESTING_LIST = [
'test_var_conv_2d'
,
'test_var_conv_2d'
,
'test_batch_norm_mkldnn_op'
,
'test_batch_norm_mkldnn_op'
,
'test_concat_int8_mkldnn_op'
,
'test_concat_int8_mkldnn_op'
,
'test_concat_bf16_mkldnn_op'
,
'test_concat_mkldnn_op'
,
'test_concat_mkldnn_op'
,
'test_conv2d_bf16_mkldnn_op'
,
'test_conv2d_bf16_mkldnn_op'
,
'test_conv2d_int8_mkldnn_op'
,
'test_conv2d_int8_mkldnn_op'
,
...
@@ -606,6 +608,7 @@ STATIC_MODE_TESTING_LIST = [
...
@@ -606,6 +608,7 @@ STATIC_MODE_TESTING_LIST = [
'test_multi_gru_fuse_pass'
,
'test_multi_gru_fuse_pass'
,
'test_multi_gru_seq_fuse_pass'
,
'test_multi_gru_seq_fuse_pass'
,
'test_pool2d_int8_mkldnn_op'
,
'test_pool2d_int8_mkldnn_op'
,
'test_pool2d_bf16_mkldnn_op'
,
'test_pool2d_mkldnn_op'
,
'test_pool2d_mkldnn_op'
,
'test_quantize_mkldnn_op'
,
'test_quantize_mkldnn_op'
,
'test_requantize_mkldnn_op'
,
'test_requantize_mkldnn_op'
,
...
@@ -614,6 +617,7 @@ STATIC_MODE_TESTING_LIST = [
...
@@ -614,6 +617,7 @@ STATIC_MODE_TESTING_LIST = [
'test_sum_mkldnn_op'
,
'test_sum_mkldnn_op'
,
'test_sum_bf16_mkldnn_op'
,
'test_sum_bf16_mkldnn_op'
,
'test_transpose_int8_mkldnn_op'
,
'test_transpose_int8_mkldnn_op'
,
'test_transpose_bf16_mkldnn_op'
,
'test_transpose_mkldnn_op'
,
'test_transpose_mkldnn_op'
,
'test_mkldnn_conv_activation_fuse_pass'
,
'test_mkldnn_conv_activation_fuse_pass'
,
'test_mkldnn_conv_concat_relu_mkldnn_fuse_pass'
,
'test_mkldnn_conv_concat_relu_mkldnn_fuse_pass'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录