From aa9fdd0d664204825adfd615dfb96a230b5fafd7 Mon Sep 17 00:00:00 2001 From: jiangcheng Date: Mon, 5 Jul 2021 19:38:28 +0800 Subject: [PATCH] add `reduce_sum` op into amp black list (#33960) * reduce sum op default fp32, add into amp black list * reduce_sum default fp32 can avoid return inf when the sum value large than 65504 --- python/paddle/fluid/contrib/mixed_precision/fp16_lists.py | 2 ++ python/paddle/fluid/dygraph/amp/auto_cast.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/python/paddle/fluid/contrib/mixed_precision/fp16_lists.py b/python/paddle/fluid/contrib/mixed_precision/fp16_lists.py index 18f635ee80..efa9caaee8 100644 --- a/python/paddle/fluid/contrib/mixed_precision/fp16_lists.py +++ b/python/paddle/fluid/contrib/mixed_precision/fp16_lists.py @@ -99,6 +99,8 @@ black_list = { # fp16 is slower than fp32, though fp16 is supported. 'lookup_table', 'lookup_table_v2', + # default fp32 can avoid return inf when the sum value large than 65504 + 'reduce_sum', } # This set contains two types of ops. All ops supported fp16 calculation. One diff --git a/python/paddle/fluid/dygraph/amp/auto_cast.py b/python/paddle/fluid/dygraph/amp/auto_cast.py index 7af8c18e33..bd464450ae 100644 --- a/python/paddle/fluid/dygraph/amp/auto_cast.py +++ b/python/paddle/fluid/dygraph/amp/auto_cast.py @@ -47,6 +47,8 @@ BLACK_LIST = { 'sigmoid_cross_entropy_with_logits', 'cross_entropy', 'cross_entropy2', + # default fp32 can avoid return inf when the sum value large than 65504 + 'reduce_sum', } AMP_RELATED_FLAGS = [ -- GitLab