diff options
author | Giorgio Arena <giorgio.arena@arm.com> | 2018-09-04 14:55:55 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:54:54 +0000 |
commit | 73023027d6250daaa1df49fdeb1d21e59a0bf7f5 (patch) | |
tree | fbe02771dde050fa1c386881cc6ff43d1ea10e05 /tests/validation/reference/ActivationLayer.h | |
parent | 555d1109dd566661bcf911c28030927cf4fde5b4 (diff) | |
download | ComputeLibrary-73023027d6250daaa1df49fdeb1d21e59a0bf7f5.tar.gz |
COMPMID-1539 Implement YOLOLayer on CL
Change-Id: I332c0703e1399fca0c5b724529b54a28f49c88da
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/146842
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'tests/validation/reference/ActivationLayer.h')
-rw-r--r-- | tests/validation/reference/ActivationLayer.h | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/tests/validation/reference/ActivationLayer.h b/tests/validation/reference/ActivationLayer.h index 09f602ffa1..c752e74733 100644 --- a/tests/validation/reference/ActivationLayer.h +++ b/tests/validation/reference/ActivationLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -35,6 +35,54 @@ namespace validation { namespace reference { +template <typename T> +inline T activate_float(T x, T a, T b, ActivationLayerInfo::ActivationFunction activation) +{ + T ret; + + switch(activation) + { + case ActivationLayerInfo::ActivationFunction::ABS: + ret = std::abs(x); + break; + case ActivationLayerInfo::ActivationFunction::LINEAR: + ret = a * x + b; + break; + case ActivationLayerInfo::ActivationFunction::LOGISTIC: + ret = static_cast<T>(1) / (static_cast<T>(1) + std::exp(-x)); + break; + case ActivationLayerInfo::ActivationFunction::RELU: + ret = std::max<T>(static_cast<T>(0), x); + break; + case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU: + ret = std::min<T>(a, std::max(static_cast<T>(0), x)); + break; + case ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU: + ret = std::min<T>(a, std::max<T>(b, x)); + break; + case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: + ret = (x > 0) ? x : a * x; + break; + case ActivationLayerInfo::ActivationFunction::SOFT_RELU: + ret = std::log(static_cast<T>(1) + std::exp(x)); + break; + case ActivationLayerInfo::ActivationFunction::SQRT: + ret = std::sqrt(x); + break; + case ActivationLayerInfo::ActivationFunction::SQUARE: + ret = x * x; + break; + case ActivationLayerInfo::ActivationFunction::TANH: + ret = a * std::tanh(b * x); + break; + default: + ARM_COMPUTE_ERROR("Unsupported activation function"); + break; + } + + return ret; +} + template <typename T, typename std::enable_if<is_floating_point<T>::value, int>::type = 0> SimpleTensor<T> activation_layer(const SimpleTensor<T> &src, ActivationLayerInfo info); |