aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Kunze <eric.kunze@arm.com>2021-03-16 14:27:56 -0700
committerEric Kunze <eric.kunze@arm.com>2021-03-18 11:03:05 -0700
commitc30004c4a865c709c65b441031ab3fed9a4be5bc (patch)
tree4310970bfd4f5aa5895adf851e0158a4567071ed
parent71b02b19a1bc9c73b3f2ac9b65086151588e3e27 (diff)
downloadspecification-c30004c4a865c709c65b441031ab3fed9a4be5bc.tar.gz
Add integer DIV operator
Integer divide is not commonly used, but would have been difficult to implement using the existing operators. Signed-off-by: Eric Kunze <eric.kunze@arm.com> Change-Id: I8fb3919cd7a0f1a1fa95074d921d200d23e2f249
-rw-r--r--chapters/ewise_binary.adoc40
1 files changed, 40 insertions, 0 deletions
diff --git a/chapters/ewise_binary.adoc b/chapters/ewise_binary.adoc
index 6a5c575..18518bd 100644
--- a/chapters/ewise_binary.adoc
+++ b/chapters/ewise_binary.adoc
@@ -208,6 +208,46 @@ for_each(index in shape) {
|Any|signed 32|int32_t
|===
+==== DIV
+
+Elementwise divide of input1 by input2.
+The result of the divide is truncated towards zero.
+Only used for integer operation.
+Floating point divide should use RECIPROCAL and MUL.
+
+*Arguments:*
+
+|===
+|Argument|Type|Name|Shape|Description
+
+|Input|in_t*|input1|shape1|Input tensor
+|Input|in_t*|input2|shape2|Input tensor with the same rank as input1
+|Output|in_t*|output|shape|Output tensor with broadcast shape if necessary
+|===
+
+*Operation Function:*
+
+[source,c++]
+----
+for_each(index in shape) {
+ index1 = apply_broadcast(shape, shape1, index);
+ index2 = apply_broadcast(shape, shape2, index);
+ in_t value1 = tensor_read<in_t>(input1, shape1, index1);
+ in_t value2 = tensor_read<in_t>(input2, shape2, index2);
+ assert(value2 != 0);
+ assert((int64_t)value1 / value2 <= maximum<in_t>);
+ in_t acc = value1 / value2;
+ tensor_write<in_t>(output, shape, index, acc);
+}
+----
+
+*Supported Data Types:*
+|===
+|Profile|Mode|in_t
+
+|Any|signed 32|int32_t
+|===
+
==== LOGICAL_AND
Elementwise logical AND of input1 and input2.