From 9a560f7c7e29486093e6cbb91e85cda8b949c886 Mon Sep 17 00:00:00 2001 From: Zhang Ting Date: Mon, 29 Aug 2022 10:07:14 +0800 Subject: [PATCH] add interpolate op to default black lists (#45393) --- .../fluid/contrib/mixed_precision/fp16_lists.py | 5 +++++ .../paddle/fluid/contrib/tests/test_amp_list.py | 7 +++++++ python/paddle/fluid/dygraph/amp/auto_cast.py | 17 ++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/python/paddle/fluid/contrib/mixed_precision/fp16_lists.py b/python/paddle/fluid/contrib/mixed_precision/fp16_lists.py index 7b2546f70a..b2767b1dd1 100644 --- a/python/paddle/fluid/contrib/mixed_precision/fp16_lists.py +++ b/python/paddle/fluid/contrib/mixed_precision/fp16_lists.py @@ -107,6 +107,11 @@ black_list = { # fp16 is slower than fp32, though fp16 is supported. 'lookup_table', 'lookup_table_v2', + 'linear_interp_v2', + 'nearest_interp_v2', + 'bilinear_interp_v2', + 'bicubic_interp_v2', + 'trilinear_interp_v2', # default fp32 can avoid return inf when the sum value large than 65504 'reduce_sum', } diff --git a/python/paddle/fluid/contrib/tests/test_amp_list.py b/python/paddle/fluid/contrib/tests/test_amp_list.py index fb46df1377..93c99b5ea1 100644 --- a/python/paddle/fluid/contrib/tests/test_amp_list.py +++ b/python/paddle/fluid/contrib/tests/test_amp_list.py @@ -30,6 +30,13 @@ class TestAMPList(unittest.TestCase): self.assertTrue(op not in amp_list.black_list) self.assertTrue(op not in amp_list.unsupported_list) + default_black_list = [ + 'linear_interp_v2', 'nearest_interp_v2', 'bilinear_interp_v2', + 'bicubic_interp_v2', 'trilinear_interp_v2' + ] + for op in default_black_list: + self.assertTrue(op in amp_list.black_list) + if __name__ == "__main__": unittest.main() diff --git a/python/paddle/fluid/dygraph/amp/auto_cast.py b/python/paddle/fluid/dygraph/amp/auto_cast.py index 49c0368434..87df808213 100644 --- a/python/paddle/fluid/dygraph/amp/auto_cast.py +++ b/python/paddle/fluid/dygraph/amp/auto_cast.py @@ -56,6 +56,12 @@ BLACK_LIST = { 'cross_entropy2', # default fp32 can avoid return inf when the sum value large than 65504 'reduce_sum', + # FP16 performance of grad op is worse than that of FP32. Use FP32 by default. + 'linear_interp_v2', + 'nearest_interp_v2', + 'bilinear_interp_v2', + 'bicubic_interp_v2', + 'trilinear_interp_v2', } AMP_RELATED_FLAGS = [ @@ -72,7 +78,16 @@ AMP_RELATED_FLAGS_SETTING = { PURE_FP16_WHITE_LIST = {' '} PURE_FP16_BLACK_LIST = { - 'lookup_table', 'lookup_table_v2', 'scatter', 'scatter_grad' + 'lookup_table', + 'lookup_table_v2', + 'scatter', + 'scatter_grad', + # FP16 performance of grad op is worse than that of FP32. Use FP32 by default. + 'linear_interp_v2', + 'nearest_interp_v2', + 'bilinear_interp_v2', + 'bicubic_interp_v2', + 'trilinear_interp_v2', } BF16_WHITE_LIST = {'conv2d', 'matmul_v2'} -- GitLab