From c30004c4a865c709c65b441031ab3fed9a4be5bc Mon Sep 17 00:00:00 2001 From: Eric Kunze Date: Tue, 16 Mar 2021 14:27:56 -0700 Subject: 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 Change-Id: I8fb3919cd7a0f1a1fa95074d921d200d23e2f249 --- chapters/ewise_binary.adoc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) 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(input1, shape1, index1); + in_t value2 = tensor_read(input2, shape2, index2); + assert(value2 != 0); + assert((int64_t)value1 / value2 <= maximum); + in_t acc = value1 / value2; + tensor_write(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. -- cgit v1.2.1