From a694e679763ff13dbde2d25f0ff125d3bbf6c6fe Mon Sep 17 00:00:00 2001 From: gouzil <66515297+gouzil@users.noreply.github.com> Date: Tue, 29 Aug 2023 10:35:11 +0800 Subject: [PATCH] [clang-tidy] enable clang-analyzer-core.UndefinedBinaryOperatorResult (#56636) --- .clang-tidy | 2 +- paddle/phi/kernels/funcs/activation_functor.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 23da1367f9f..e25b6d33bdc 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -58,7 +58,7 @@ bugprone-unused-raii, -clang-analyzer-core.NullDereference, -clang-analyzer-core.StackAddrEscapeBase, -clang-analyzer-core.StackAddressEscape, --clang-analyzer-core.UndefinedBinaryOperatorResult, +clang-analyzer-core.UndefinedBinaryOperatorResult, -clang-analyzer-core.VLASize, -clang-analyzer-core.builtin.BuiltinFunctions, -clang-analyzer-core.builtin.NoReturnFunctions, diff --git a/paddle/phi/kernels/funcs/activation_functor.h b/paddle/phi/kernels/funcs/activation_functor.h index 1d3bde7ab59..926920dfa93 100644 --- a/paddle/phi/kernels/funcs/activation_functor.h +++ b/paddle/phi/kernels/funcs/activation_functor.h @@ -1488,7 +1488,7 @@ struct LeakyReluFunctor : public BaseActivationFunctor { template void operator()(Device d, X x, Out out) const { - if (alpha < 1.f) { + if (alpha < 1.f) { // NOLINT out.device(d) = x.cwiseMax(static_cast(alpha) * x); } else { out.device(d) = x.cwiseMin(static_cast(alpha) * x); @@ -1653,7 +1653,7 @@ struct HardShrinkFunctor : public BaseActivationFunctor { } template void operator()(Device d, X x, Out out) const { - auto temp1 = x < static_cast(threshold * -1.f); + auto temp1 = x < static_cast(threshold * -1.f); // NOLINT auto temp2 = x > static_cast(threshold); out.device(d) = x * (temp1 || temp2).template cast(); } @@ -1673,7 +1673,7 @@ struct HardShrinkGradFunctor : public BaseActivationFunctor { typename dOut, typename dX> void operator()(Device d, X x, Out out UNUSED, dOut dout, dX dx) const { - auto temp1 = x < static_cast(threshold * -1.f); + auto temp1 = x < static_cast(threshold * -1.f); // NOLINT auto temp2 = x > static_cast(threshold); dx.device(d) = dout * (temp1 || temp2).template cast(); } @@ -2565,7 +2565,7 @@ struct CELUGradFunctor : public BaseActivationFunctor { typename dOut, typename dX> void operator()(Device d, X x, Out out UNUSED, dOut dout, dX dx) const { - auto temp_a_pos = static_cast(alpha > 0); + auto temp_a_pos = static_cast(alpha > 0); // NOLINT auto temp_a_neg = static_cast(alpha <= 0); auto temp_x_pos = (x > static_cast(0)).template cast(); auto temp_x_neg = (x <= static_cast(0)).template cast(); -- GitLab