blob: 523649c65d318409e3d75364f45694ab24ddead8 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2016, 2017 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#ifndef __ARM_COMPUTE_NEMATH_H__
25#define __ARM_COMPUTE_NEMATH_H__
26
27#include <arm_neon.h>
28
29namespace arm_compute
30{
Georgios Pinitasd8e765b2017-08-02 13:44:33 +010031/** Calculate floor of a vector.
32 *
33 * @param[in] val Input vector value in F32 format.
34 *
35 * @return The calculated floor vector.
36 */
37float32x4_t vfloorq_f32(float32x4_t val);
38
Anthony Barbier6ff3b192017-09-04 18:44:23 +010039/** Calculate inverse square root.
40 *
41 * @param[in] x Input value.
42 *
43 * @return The calculated inverse square root.
44 */
45float32x4_t vinvsqrtq_f32(float32x4_t x);
46
Pablo Tello8fda1cb2017-07-05 15:20:38 +010047#ifdef ARM_COMPUTE_ENABLE_FP16
48/** Calculate inverse square root.
49 *
50 * @param[in] x Input value.
51 *
52 * @return The calculated inverse square root.
53 */
54float16x8_t vinvsqrtq_f16(float16x8_t x);
55#endif /* ARM_COMPUTE_ENABLE_FP16 */
56
Anthony Barbier6ff3b192017-09-04 18:44:23 +010057/** Calculate reciprocal.
58 *
59 * @param[in] x Input value.
60 *
61 * @return The calculated reciprocal.
62 */
63float32x4_t vinvq_f32(float32x4_t x);
64
65/** Perform a 7th degree polynomial approximation using Estrin's method.
66 *
67 * @param[in] x Input vector value in F32 format.
68 * @param[in] coeffs Polynomial coefficients table.
69 *
70 * @return The calculated approximation.
71 */
72float32x4_t vtaylor_polyq_f32(float32x4_t x, const std::array<float32x4_t, 8> &coeffs);
73
74/** Calculate exponential
75 *
76 * @param[in] x Input vector value in F32 format.
77 *
78 * @return The calculated exponent.
79 */
80float32x4_t vexpq_f32(float32x4_t x);
81
82/** Calculate logarithm
83 *
84 * @param[in] x Input vector value in F32 format.
85 *
86 * @return The calculated logarithm.
87 */
88float32x4_t vlogq_f32(float32x4_t x);
89
90/** Calculate hyperbolic tangent.
91 *
92 * tanh(x) = (e^2x - 1)/(e^2x + 1)
93 *
94 * @note We clamp x to [-5,5] to avoid overflowing issues.
95 *
96 * @param[in] val Input vector value in F32 format.
97 *
98 * @return The calculated Hyperbolic Tangent.
99 */
100float32x4_t vtanhq_f32(float32x4_t val);
101
102/** Calculate n power of a number.
103 *
104 * pow(x,n) = e^(n*log(x))
105 *
106 * @param[in] val Input vector value in F32 format.
107 * @param[in] n Powers to raise the input to.
108 *
109 * @return The calculated power.
110 */
111float32x4_t vpowq_f32(float32x4_t val, float32x4_t n);
Pablo Tellodf246182017-07-03 16:25:09 +0100112
113#ifdef ARM_COMPUTE_ENABLE_FP16
Pablo Tello91654c42017-07-05 11:32:17 +0100114/** Calculate hyperbolic tangent.
115 *
116 * tanh(x) = (e^2x - 1)/(e^2x + 1)
117 *
118 * @note We clamp x to [-5,5] to avoid overflowing issues.
119 *
120 * @param[in] val Input vector value in F32 format.
121 *
122 * @return The calculated Hyperbolic Tangent.
123 */
124float16x8_t vtanhq_f16(float16x8_t val);
125/** Calculate inverse square root.
126 *
127 * @param[in] x Input value.
128 *
129 * @return The calculated inverse square root.
130 */
131float16x8_t vinvsqrtq_f16(float16x8_t x);
Pablo Tellodf246182017-07-03 16:25:09 +0100132/** Calculate exponential
133 *
134 * @param[in] x Input vector value in F16 format.
135 *
136 * @return The calculated exponent.
137 */
138float16x8_t vexpq_f16(float16x8_t x);
139/** Calculate n power of a number.
140 *
141 * pow(x,n) = e^(n*log(x))
142 *
143 * @param[in] val Input vector value in F16 format.
144 * @param[in] n Powers to raise the input to.
145 *
146 * @return The calculated power.
147 */
148float16x8_t vpowq_f16(float16x8_t val, float16x8_t n);
149#endif /* ARM_COMPUTE_ENABLE_FP16 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100150}
151#include "arm_compute/core/NEON/NEMath.inl"
152#endif /* __ARM_COMPUTE_NEMATH_H__ */