aboutsummaryrefslogtreecommitdiff
path: root/src/core/CL/cl_kernels/activation_layer.cl
diff options
context:
space:
mode:
authorGian Marco Iodice <gianmarco.iodice@arm.com>2017-06-20 09:07:21 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-09-17 14:14:20 +0100
commitb30dcc5ab8eb2bd37f0ab742af1ec45113d54296 (patch)
treedfaac2b07af3ffb838d3ed559bacf8f37da3b592 /src/core/CL/cl_kernels/activation_layer.cl
parent9ea47f6967ce1c9e4a8bf4174613efdec78a5f44 (diff)
downloadComputeLibrary-b30dcc5ab8eb2bd37f0ab742af1ec45113d54296.tar.gz
COMPMID-345 - In-place computation for Activation Layer
Change-Id: I25ebfccc3d3e758cc8164e0b33805c0bb303891a Reviewed-on: http://mpd-gerrit.cambridge.arm.com/78226 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Pablo Tello <pablo.tello@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'src/core/CL/cl_kernels/activation_layer.cl')
-rw-r--r--src/core/CL/cl_kernels/activation_layer.cl18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/core/CL/cl_kernels/activation_layer.cl b/src/core/CL/cl_kernels/activation_layer.cl
index e3cbb6c801..136191aa22 100644
--- a/src/core/CL/cl_kernels/activation_layer.cl
+++ b/src/core/CL/cl_kernels/activation_layer.cl
@@ -25,6 +25,8 @@
/** This performs an activation function floating point inputs.
*
+ * @note In order to perform the activation function "in-place", the pre-processor -DIN_PLACE must be passed at compile time
+ *
* @note Datatype should be given as a preprocessor argument using -DDATA_TYPE=type. e.g. -DDATA_TYPE=short
* @note Activation function should be given as a preprocessor argument using -DNAME. e.g. -DTANH
* @note Distinction between floating point and integer is done using -DTYPE_FP and -DTYPE_INT preprocessor argument
@@ -48,12 +50,20 @@
* @param[in] output_offset_first_element_in_bytes The offset of the first element in the destination image
*/
__kernel void activation_layer(
- TENSOR3D_DECLARATION(input),
- TENSOR3D_DECLARATION(output))
+ TENSOR3D_DECLARATION(input)
+#if !defined IN_PLACE
+ ,
+ TENSOR3D_DECLARATION(output)
+#endif
+)
{
// Get pixels pointer
- Tensor3D input = CONVERT_TO_TENSOR3D_STRUCT(input);
+ Tensor3D input = CONVERT_TO_TENSOR3D_STRUCT(input);
+#if defined IN_PLACE
+ Tensor3D output = input;
+#else
Tensor3D output = CONVERT_TO_TENSOR3D_STRUCT(output);
+#endif
// Load data
VEC_DATA_TYPE(DATA_TYPE, 16)
@@ -63,7 +73,7 @@ __kernel void activation_layer(
#if defined LOGISTIC
data = 1 / (1 + exp(-data));
#elif defined TANH
- data = (VEC_DATA_TYPE(DATA_TYPE, 16))A * tanh((VEC_DATA_TYPE(DATA_TYPE, 16))B * data);
+ data = (VEC_DATA_TYPE(DATA_TYPE, 16))A * tanh((VEC_DATA_TYPE(DATA_TYPE, 16))B * data);
#elif defined RELU
data = max(0, data);
#elif defined BRELU