From d4dda8628e40d7604f30b396916f1e6802a090a1 Mon Sep 17 00:00:00 2001 From: GaoWei8 <53294385+GaoWei8@users.noreply.github.com> Date: Mon, 23 Dec 2019 12:09:56 +0800 Subject: [PATCH] optimize fc jit (#21878) test=develop --- paddle/fluid/operators/math/fc.cc | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/paddle/fluid/operators/math/fc.cc b/paddle/fluid/operators/math/fc.cc index 27a75f7631a..9309a992f73 100644 --- a/paddle/fluid/operators/math/fc.cc +++ b/paddle/fluid/operators/math/fc.cc @@ -61,27 +61,20 @@ class FCFunctor { "When bias is NULL, relu can not be true.")); return; } - if (relu) { - auto compute = - jit::KernelFuncs, platform::CPUPlace>::Cache() - .At(N); - for (int i = 0; i < M; i++) { - T* dst = Y + i * N; - T* src = (padding_weights) ? Y1_data + i * (N + 4) : dst; - compute(B, src, dst, N); - } - } else { - auto compute = - jit::KernelFuncs, platform::CPUPlace>::Cache().At( - N); + auto compute = + relu + ? jit::KernelFuncs, + platform::CPUPlace>::Cache() + .At(N) + : jit::KernelFuncs, platform::CPUPlace>::Cache() + .At(N); #ifdef PADDLE_WITH_MKLML #pragma omp parallel for #endif - for (int i = 0; i < M; i++) { - T* dst = Y + i * N; - T* src = (padding_weights) ? Y1_data + i * (N + 4) : dst; - compute(B, src, dst, N); - } + for (int i = 0; i < M; i++) { + T* dst = Y + i * N; + T* src = (padding_weights) ? Y1_data + i * (N + 4) : dst; + compute(B, src, dst, N); } } }; -- GitLab