diff options
author | Eric Kunze <eric.kunze@arm.com> | 2023-05-10 16:41:13 -0700 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2023-06-21 17:03:10 +0000 |
commit | 52c89f40440ef5bcb318b3945bdc1463ce703b8b (patch) | |
tree | d1bc5197a8a671c4170ed07b857bde78cc5de563 /chapters | |
parent | 9efe1a95658bbb405b06b3a1d9e5ef22b8388ea5 (diff) | |
download | specification-52c89f40440ef5bcb318b3945bdc1463ce703b8b.tar.gz |
Add ERF activation function
Defined for floating-point types only.
For integer versions, a TABLE should be used.
Change-Id: Ieaec6e6eb3227c5dcd9741cddd57426002a8db4d
Signed-off-by: Eric Kunze <eric.kunze@arm.com>
Diffstat (limited to 'chapters')
-rw-r--r-- | chapters/activation_funcs.adoc | 26 | ||||
-rw-r--r-- | chapters/introduction.adoc | 2 |
2 files changed, 27 insertions, 1 deletions
diff --git a/chapters/activation_funcs.adoc b/chapters/activation_funcs.adoc index 46fa19d..1acaf56 100644 --- a/chapters/activation_funcs.adoc +++ b/chapters/activation_funcs.adoc @@ -28,6 +28,32 @@ for_each(index in shape) { } ---- +==== ERF + +// erf(z) = \frac{2}{\sqrt{\pi}} \int_{0}^{z} e^{-t^2} dt +Error function: + +.Calculation for the error function +image::erf.svg["Error function", align="center"] + +For quantized integer data types, the TABLE operator should be used instead with +the following definition. + +The ERF table has 513 entries each of 16-bit precision and covering the input range -4.0 to +4.0 in steps of 1/64. + +[source,c++] +---- +int16_t erf_reference(int16_t x) { // input x range is -256 to + 256 inclusive + F64 v = (double)x / (double)64; + v = erf(v); + return round_to_nearest_int(32768.0 * v); +} + +generate_lookup_table(&erf_table, &erf_reference); +---- + +include::{generated}/operators/ERF.adoc[] + ==== SIGMOID Applies the sigmoid logistic function to each element of the input tensor. diff --git a/chapters/introduction.adoc b/chapters/introduction.adoc index b369070..955f310 100644 --- a/chapters/introduction.adoc +++ b/chapters/introduction.adoc @@ -260,7 +260,7 @@ Otherwise:the result must be within 1 ulp of the mathematical result. Otherwise if the input is a zero the output must be an infinity of the same sign. + Otherwise the result must be within 1 ulp of the mathematical result. -| <<SIGMOID>>, <<TANH>>, <<POW>>, <<EXP>>, <<LOG>> +| <<SIGMOID>>, <<TANH>>, <<POW>>, <<EXP>>, <<LOG>>, <<ERF>> | If the input to LOG is less than zero then the result must be a NaN. + If the inputs to POW are both zero then the result must be a NaN. + If the first input to POW is less than zero and the second input is not an integer then the result must be a NaN. + |