From 72a41e504f3b606c6c7ded4235a74eeb27372215 Mon Sep 17 00:00:00 2001 From: Tao Luo Date: Wed, 29 Dec 2021 10:43:31 +0800 Subject: [PATCH] reduce compile time of amax and amin (#38534) --- .../operators/reduce_ops/reduce_min_max_op.h | 15 ++++++++------- python/paddle/tensor/math.py | 6 ++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/paddle/fluid/operators/reduce_ops/reduce_min_max_op.h b/paddle/fluid/operators/reduce_ops/reduce_min_max_op.h index dfd0c9d74d1..c36b4d74676 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_min_max_op.h +++ b/paddle/fluid/operators/reduce_ops/reduce_min_max_op.h @@ -125,13 +125,14 @@ struct AMaxOrAMinGradFunctor { HANDLE_AXIS_DIM(3, 2); HANDLE_AXIS_DIM(4, 2); HANDLE_AXIS_DIM(4, 3); - HANDLE_AXIS_DIM(5, 2); - HANDLE_AXIS_DIM(5, 3); - HANDLE_AXIS_DIM(5, 4); - HANDLE_AXIS_DIM(6, 2); - HANDLE_AXIS_DIM(6, 3); - HANDLE_AXIS_DIM(6, 4); - HANDLE_AXIS_DIM(6, 5); + // comments for accelerating compiling temporarily. + // HANDLE_AXIS_DIM(5, 2); + // HANDLE_AXIS_DIM(5, 3); + // HANDLE_AXIS_DIM(5, 4); + // HANDLE_AXIS_DIM(6, 2); + // HANDLE_AXIS_DIM(6, 3); + // HANDLE_AXIS_DIM(6, 4); + // HANDLE_AXIS_DIM(6, 5); } }; diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 12335283cd1..5f7e51598cc 100755 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -1775,7 +1775,8 @@ def amax(x, axis=None, keepdim=False, name=None): while max propagates gradient to all of them. Args: - x(Tensor): A tensor, the data type is float32, float64, int32, int64. + x(Tensor): A tensor, the data type is float32, float64, int32, int64, + the dimension is no more than 4. axis(int|list|tuple, optional): The axis along which the maximum is computed. If :attr:`None`, compute the maximum over all elements of `x` and return a Tensor with a single element, @@ -1887,7 +1888,8 @@ def amin(x, axis=None, keepdim=False, name=None): while min propagates gradient to all of them. Args: - x(Tensor): A tensor, the data type is float32, float64, int32, int64. + x(Tensor): A tensor, the data type is float32, float64, int32, int64, + the dimension is no more than 4. axis(int|list|tuple, optional): The axis along which the minimum is computed. If :attr:`None`, compute the minimum over all elements of `x` and return a Tensor with a single element, -- GitLab