blob: 3b184856bbcc64b736245729bd260f201315c875 [file] [log] [blame]
//
// This confidential and proprietary software may be used only as
// authorised by a licensing agreement from ARM Limited
// (C) COPYRIGHT 2020-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.
=== Elementwise Binary Operators
==== ADD
Elementwise addition of input1 and input2.
Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.
include::{generated}/operators/ADD.adoc[]
[source,c++]
----
include::{pseudocode}/operators/ADD.tosac[lines=10..-1]
----
==== ARITHMETIC_RIGHT_SHIFT
Elementwise arithmetic right shift of input1 by the amount specified in input2.
Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.
include::{generated}/operators/ARITHMETIC_RIGHT_SHIFT.adoc[]
[source,c++]
----
include::{pseudocode}/operators/ARITHMETIC_RIGHT_SHIFT.tosac[lines=10..-1]
----
==== BITWISE_AND
Elementwise bitwise AND of input1 and input2.
Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.
include::{generated}/operators/BITWISE_AND.adoc[]
[source,c++]
----
include::{pseudocode}/operators/BITWISE_AND.tosac[lines=10..-1]
----
==== BITWISE_OR
Elementwise bitwise OR of input1 and input2.
Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.
include::{generated}/operators/BITWISE_OR.adoc[]
[source,c++]
----
include::{pseudocode}/operators/BITWISE_OR.tosac[lines=10..-1]
----
==== BITWISE_XOR
Elementwise bitwise XOR of input1 and input2.
Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.
include::{generated}/operators/BITWISE_XOR.adoc[]
[source,c++]
----
include::{pseudocode}/operators/BITWISE_XOR.tosac[lines=10..-1]
----
==== INTDIV
Elementwise integer divide of input1 by input2.
The result of the divide is truncated towards zero.
Expected use is for operations on non-scaled integers.
Floating point divide should use RECIPROCAL and MUL.
Quantized integer divide should use TABLE (for 1/x) and MUL.
include::{generated}/operators/INTDIV.adoc[]
[source,c++]
----
include::{pseudocode}/operators/INTDIV.tosac[lines=10..-1]
----
==== LOGICAL_AND
Elementwise logical AND of input1 and input2.
Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.
include::{generated}/operators/LOGICAL_AND.adoc[]
[source,c++]
----
include::{pseudocode}/operators/LOGICAL_AND.tosac[lines=10..-1]
----
==== LOGICAL_LEFT_SHIFT
Elementwise logical left-shift of input1 by the amount specified in input2.
Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.
include::{generated}/operators/LOGICAL_LEFT_SHIFT.adoc[]
[source,c++]
----
include::{pseudocode}/operators/LOGICAL_LEFT_SHIFT.tosac[lines=10..-1]
----
==== LOGICAL_RIGHT_SHIFT
Elementwise logical right shift of input1 by the amount specified in input2.
Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.
include::{generated}/operators/LOGICAL_RIGHT_SHIFT.adoc[]
[source,c++]
----
include::{pseudocode}/operators/LOGICAL_RIGHT_SHIFT.tosac[lines=10..-1]
----
==== LOGICAL_OR
Elementwise logical OR of input1 and input2.
Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.
include::{generated}/operators/LOGICAL_OR.adoc[]
[source,c++]
----
include::{pseudocode}/operators/LOGICAL_OR.tosac[lines=10..-1]
----
==== LOGICAL_XOR
Elementwise logical XOR of input1 and input2.
Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.
include::{generated}/operators/LOGICAL_XOR.adoc[]
[source,c++]
----
include::{pseudocode}/operators/LOGICAL_XOR.tosac[lines=10..-1]
----
==== MAXIMUM
Elementwise max of input1 and input2.
Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.
include::{generated}/operators/MAXIMUM.adoc[]
[source,c++]
----
include::{pseudocode}/operators/MAXIMUM.tosac[lines=10..-1]
----
==== MINIMUM
Elementwise minimum of input1 and input2.
Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.
include::{generated}/operators/MINIMUM.adoc[]
[source,c++]
----
include::{pseudocode}/operators/MINIMUM.tosac[lines=10..-1]
----
==== MUL
Elementwise multiplication (Hadamard product) of input1 and input2.
Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.
include::{generated}/operators/MUL.adoc[]
[source,c++]
----
include::{pseudocode}/operators/MUL.tosac[lines=10..-1]
----
==== POW
Elementwise input1 value raised to the power of input2.
Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match.
include::{generated}/operators/POW.adoc[]
[source,c++]
----
include::{pseudocode}/operators/POW.tosac[lines=10..-1]
----
==== SUB
Elementwise subtraction of input1 and input2.
Axis of size 1 will be broadcast as necessary. Rank of input tensors must match.
include::{generated}/operators/SUB.adoc[]
[source,c++]
----
include::{pseudocode}/operators/SUB.tosac[lines=10..-1]
----
==== TABLE
Table lookup operation.
For int8_t TABLE operation, perform a 256 entry table lookup returning an int8_t value.
For int16_t tables, the int16_t input is treated as a fixed-point 9.7 value.
The most significant 9 bits are used to index into the table.
The fractional 7 bits are used to interpolate based on table[index] and table[index+1].
For int16_t inputs, the TABLE operator returns a 16.7 interpolated value in an int32_t.
This value can then be input to the RESCALE operator to scale to the required output data type.
Note that int16_t table has 513 values to handle table[index+1] when index=511.
An int16_t to int16_t table lookup can be constructed in TOSA as follows:
* Use the TABLE operator to produce a fixed point 16.7 interpolated result
* Use RESCALE (in_t=int32_t, out_t=int16_t, scale=1<<14, shift=21) to scale the output to int16_t range (or alternate scale as required)
include::{generated}/operators/TABLE.adoc[]
[source,c++]
----
include::{pseudocode}/operators/TABLE.tosac[lines=10..-1]
----