/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "operators/kernel/activation_kernel.h" #include "common/types.h" #include "operators/kernel/central-arm-func/activation_arm_func.h" #include "operators/math/activation.h" #if defined(__ARM_NEON__) || defined(__ARM_NEON) #include #endif namespace paddle_mobile { namespace operators { #ifdef RELU_OP template <> bool ReluKernel::Init(ReluParam *param) { return true; } template <> void ReluKernel::Compute(const ReluParam ¶m) { const LoDTensor *input = param.InputX(); LoDTensor *output = param.Out(); ActivationCompute()(input, output); output->set_lod(input->lod()); } template <> bool Relu6Kernel::Init(ReluParam *param) { return true; } template <> void Relu6Kernel::Compute(const ReluParam ¶m) { const LoDTensor *input = param.InputX(); LoDTensor *output = param.Out(); ActivationCompute()(input, output); output->set_lod(input->lod()); } #endif #ifdef SIGMOID_OP template <> bool SigmoidKernel::Init(SigmoidParam *param) { return true; } template <> void SigmoidKernel::Compute(const SigmoidParam ¶m) { const LoDTensor *input = param.InputX(); LoDTensor *output = param.Out(); ActivationCompute()(input, output); output->set_lod(input->lod()); } #endif #ifdef TANH_OP template <> bool TanhKernel::Init(TanhParam *param) { return true; } template <> void TanhKernel::Compute(const TanhParam ¶m) { const LoDTensor *input = param.InputX(); LoDTensor *output = param.Out(); ActivationCompute()(input, output); output->set_lod(input->lod()); } #endif #ifdef LOG_OP template <> bool LogKernel::Init(ReluParam *param) { return true; } template <> void LogKernel::Compute(const ReluParam ¶m) { const LoDTensor *input = param.InputX(); LoDTensor *output = param.Out(); ActivationCompute()(input, output); output->set_lod(input->lod()); } #endif #ifdef LEAKY_RELU_OP template <> bool LeakyReluKernel::Init(LeakyReluParam *param) { return true; } template <> void LeakyReluKernel::Compute(const LeakyReluParam ¶m) { const LoDTensor *input = param.InputX(); LoDTensor *output = param.Out(); ActivationCompute()(input, output, param.Alpha()); output->set_lod(input->lod()); } #endif } // namespace operators } // namespace paddle_mobile