diff options
-rw-r--r-- | chapters/ewise_unary.adoc | 36 | ||||
-rw-r--r-- | chapters/introduction.adoc | 12 | ||||
-rw-r--r-- | pseudocode/operators/COS.tosac | 14 | ||||
-rw-r--r-- | pseudocode/operators/SIN.tosac | 14 | ||||
-rw-r--r-- | tosa.xml | 58 |
5 files changed, 134 insertions, 0 deletions
diff --git a/chapters/ewise_unary.adoc b/chapters/ewise_unary.adoc index 4b8cd4d..e2d3779 100644 --- a/chapters/ewise_unary.adoc +++ b/chapters/ewise_unary.adoc @@ -67,6 +67,24 @@ include::{generated}/operators/CLZ.adoc[] include::{pseudocode}/operators/CLZ.tosac[lines=10..-1] ---- +==== COS + +Elementwise cosine operation for values given in radians. + +include::{generated}/operators/COS.adoc[] + +[source, c++] +---- +include::{pseudocode}/operators/COS.tosac[] +---- + +*Floating-point behavior:* +|=== +|Input|-infinity|+infinity|-0|+0|NaN + +|Output|NaN|NaN|+1|+1|NaN +|=== + ==== EXP Elementwise e to the x operation @@ -185,3 +203,21 @@ include::{generated}/operators/RSQRT.adoc[] ---- include::{pseudocode}/operators/RSQRT.tosac[lines=10..-1] ---- + +==== SIN + +Elementwise sine operation for values given in radians. + +include::{generated}/operators/COS.adoc[] + +[source, c++] +---- +include::{pseudocode}/operators/COS.tosac[] +---- + +*Floating-point behavior:* +|=== +|Input|-infinity|+infinity|-0|+0|NaN + +|Output|NaN|NaN|-0|+0|NaN +|=== diff --git a/chapters/introduction.adoc b/chapters/introduction.adoc index 17c16a8..a580472 100644 --- a/chapters/introduction.adoc +++ b/chapters/introduction.adoc @@ -309,6 +309,18 @@ Let n be number of elements in the product, out_imp the implementation result, a Let `err_bnd = abs(out_ref) * (pow(1 + pow(2, -normal_frac<in_out_t> - 1), n) - 1)` + Then `tosa_reference_check_fp_bnd<in_out_t>(out_imp, out_ref, err_bnd)` must be true +| <<COS>> +| Let `x` be an input element and `out_imp` the implementation output of `cos(x)`. + +Let `out_ref` be the result of the fp64_t reference implementation of `cos(x)`. + +Let `err_bnd = abs(out_ref) * exp2(-normal_frac<in_out_t>/2)` + +Then `tosa_reference_check_fp_bnd<in_out_t>(out_imp, out_ref, err_bnd)` must be true + +| <<SIN>> +| Let `x` be an input element and `out_imp` the implementation output of `sin(x)`. + +Let `out_ref` be the result of the fp64_t reference implementation of `sin(x)`. + +Let `err_bnd = abs(out_ref) * exp2(-normal_frac<in_out_t>/2)` + +Then `tosa_reference_check_fp_bnd<in_out_t>(out_imp, out_ref, err_bnd)` must be true + |=== ===== Operator sequence precision requirement diff --git a/pseudocode/operators/COS.tosac b/pseudocode/operators/COS.tosac new file mode 100644 index 0000000..e1f1d91 --- /dev/null +++ b/pseudocode/operators/COS.tosac @@ -0,0 +1,14 @@ +// +// This confidential and proprietary software may be used only as +// authorised by a licensing agreement from ARM Limited +// (C) COPYRIGHT 2024 ARM Limited +// ALL RIGHTS RESERVED +// The entire notice above must be reproduced on all authorised +// copies and copies may only be made to the extent permitted +// by a licensing agreement from ARM Limited. + +for_each(index in shape) { + in_out_t value1 = tensor_read<in_out_t>(input, shape, index); + value = cos<in_out_t>(value1); + tensor_write<in_out_t>(output, shape, index, value); +} diff --git a/pseudocode/operators/SIN.tosac b/pseudocode/operators/SIN.tosac new file mode 100644 index 0000000..9a24a00 --- /dev/null +++ b/pseudocode/operators/SIN.tosac @@ -0,0 +1,14 @@ +// +// This confidential and proprietary software may be used only as +// authorised by a licensing agreement from ARM Limited +// (C) COPYRIGHT 2024 ARM Limited +// ALL RIGHTS RESERVED +// The entire notice above must be reproduced on all authorised +// copies and copies may only be made to the extent permitted +// by a licensing agreement from ARM Limited. + +for_each(index in shape) { + in_out_t value1 = tensor_read<in_out_t>(input, shape, index); + value = sin<in_out_t>(value1); + tensor_write<in_out_t>(output, shape, index, value); +} @@ -1428,6 +1428,35 @@ </types> <typesupport mode="signed 32" in_out_t="i32_t"/> </operator> + <operator> + <name>COS</name> + <arguments> + <argument category="input" name="input" type="tensor_t" shape="shape" tensor-element-type="in_out_t"> + <description>Input tensor</description> + <levellimit value="rank(shape)" limit="MAX_RANK"/> + <rank min="0" max="MAX_RANK"/> + </argument> + <argument category="output" name="output" type="tensor_t" shape="shape" tensor-element-type="in_out_t"> + <description>Output tensor of same type and shape as input</description> + <rank min="0" max="MAX_RANK"/> + </argument> + </arguments> + <types> + <type name='in_out_t'/> + </types> + <typesupport mode="fp16" in_out_t="fp16_t"> + <profile name="MI"/> + <profile name="MT"/> + </typesupport> + <typesupport mode="bf16" in_out_t="bf16_t"> + <profile name="MI"/> + <profile name="MT"/> + </typesupport> + <typesupport mode="fp32" in_out_t="fp32_t"> + <profile name="MI"/> + <profile name="MT"/> + </typesupport> + </operator> <operator> <name>EXP</name> <arguments> @@ -1675,6 +1704,35 @@ <profile name="MT"/> </typesupport> </operator> + <operator> + <name>SIN</name> + <arguments> + <argument category="input" name="input" type="tensor_t" shape="shape" tensor-element-type="in_out_t"> + <description>Input tensor</description> + <levellimit value="rank(shape)" limit="MAX_RANK"/> + <rank min="0" max="MAX_RANK"/> + </argument> + <argument category="output" name="output" type="tensor_t" shape="shape" tensor-element-type="in_out_t"> + <description>Output tensor of same type and shape as input</description> + <rank min="0" max="MAX_RANK"/> + </argument> + </arguments> + <types> + <type name='in_out_t'/> + </types> + <typesupport mode="fp16" in_out_t="fp16_t"> + <profile name="MI"/> + <profile name="MT"/> + </typesupport> + <typesupport mode="bf16" in_out_t="bf16_t"> + <profile name="MI"/> + <profile name="MT"/> + </typesupport> + <typesupport mode="fp32" in_out_t="fp32_t"> + <profile name="MI"/> + <profile name="MT"/> + </typesupport> + </operator> </operatorgroup> <operatorgroup name="comparison"> <operator> |