Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
9dbc8f02
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
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看板
未验证
提交
9dbc8f02
编写于
8月 25, 2023
作者:
N
niuliling123
提交者:
GitHub
8月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Set bf16 black_list and white_list (#55713)
上级
cd450c0a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
34 deletion
+18
-34
python/paddle/amp/amp_lists.py
python/paddle/amp/amp_lists.py
+12
-6
python/paddle/static/amp/bf16/amp_lists.py
python/paddle/static/amp/bf16/amp_lists.py
+3
-25
test/contrib/test_bf16_utils.py
test/contrib/test_bf16_utils.py
+3
-3
未找到文件。
python/paddle/amp/amp_lists.py
浏览文件 @
9dbc8f02
...
...
@@ -12,22 +12,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# The set of ops that support fp16 calculation and are considered numerically-
# safe and performance-critical. These ops are always converted to fp16.
FP16_
WHITE_LIST
=
{
# The set of ops that support fp16
and bf16
calculation and are considered numerically-
# safe and performance-critical. These ops are always converted to fp16
or bf16
.
WHITE_LIST
=
{
'conv2d'
,
'einsum'
,
'matmul'
,
'matmul_v2'
,
'max_pool2d_with_index'
,
'mul'
,
'fused_gemm_epilogue'
,
}
# The set of ops that support fp16, and bf16 was unsupported.
ONLY_FP16_WHITE_LIST
=
{
'fake_quantize_dequantize_abs_max'
,
'fake_quantize_dequantize_moving_average_abs_max'
,
'fused_gemm_epilogue'
,
'fused_attention'
,
'fused_feedforward'
,
}
FP16_WHITE_LIST
=
WHITE_LIST
|
ONLY_FP16_WHITE_LIST
# The set of ops that support fp16 calculation and are considered numerically-
# dangerous and whose effects may also be observed in downstream ops.
FP16_BLACK_LIST
=
{
...
...
@@ -90,8 +96,8 @@ EXTRA_BLACK_LIST = {
'scatter'
,
}
BF16_WHITE_LIST
=
{
'conv2d'
,
'einsum'
,
'matmul_v2'
}
BF16_BLACK_LIST
=
set
()
BF16_WHITE_LIST
=
WHITE_LIST
BF16_BLACK_LIST
=
FP16_BLACK_LIST
# At OD level, ops in WHITE_LIST will use FP16/BF16 and the others will use FP32.
...
...
python/paddle/static/amp/bf16/amp_lists.py
浏览文件 @
9dbc8f02
...
...
@@ -14,6 +14,7 @@
import
copy
from
paddle.amp.amp_lists
import
BF16_WHITE_LIST
from
paddle.fluid
import
core
from
..fp16_lists
import
black_list
as
black_list_fp16
...
...
@@ -86,33 +87,10 @@ class AutoMixedPrecisionListsBF16:
bf16_initializer_list
=
{
'fill_constant'
,
'uniform_random'
}
# always bf16
bf16_list
=
{
'conv2d'
,
'matmul'
,
'matmul_v2'
,
'mul'
,
}
bf16_list
=
BF16_WHITE_LIST
# depends on the prev_op type
gray_list
=
{
'elementwise_add'
,
'elementwise_sub'
,
'elementwise_mul'
,
'elementwise_div'
,
'relu'
,
'layer_norm'
,
'slice'
,
'concat'
,
'uniform_random'
,
'reshape2'
,
'transpose2'
,
'pool2d'
,
'sigmoid'
,
'cast'
,
'scale'
,
'fill_constant'
,
'split'
,
}
gray_list
=
gray_list_fp16
_
,
_
,
_sys_unsupported_bf16_list
=
core
.
op_supported_infos
(
'CPU'
,
core
.
VarDesc
.
VarType
.
BF16
...
...
test/contrib/test_bf16_utils.py
浏览文件 @
9dbc8f02
...
...
@@ -46,10 +46,10 @@ class AMPTest(unittest.TestCase):
def
test_amp_lists_2
(
self
):
# 2. w={'tanh'}, b=None
self
.
fp32_list
.
remove
(
'tan
h
'
)
self
.
bf16_list
.
add
(
'tan
h
'
)
self
.
fp32_list
.
remove
(
'tan'
)
self
.
bf16_list
.
add
(
'tan'
)
self
.
amp_lists_
=
amp
.
bf16
.
AutoMixedPrecisionListsBF16
({
'tan
h
'
})
self
.
amp_lists_
=
amp
.
bf16
.
AutoMixedPrecisionListsBF16
({
'tan'
})
def
test_amp_lists_3
(
self
):
# 3. w={'lstm'}, b=None
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录