aboutsummaryrefslogtreecommitdiff
path: root/chapters/ewise_binary.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'chapters/ewise_binary.adoc')
-rw-r--r--chapters/ewise_binary.adoc8
1 files changed, 7 insertions, 1 deletions
diff --git a/chapters/ewise_binary.adoc b/chapters/ewise_binary.adoc
index 4da63de..241ca32 100644
--- a/chapters/ewise_binary.adoc
+++ b/chapters/ewise_binary.adoc
@@ -479,6 +479,7 @@ Elementwise multiplication (Hadamard product) of input tensor 0 and input tensor
|Input|in_t*|input1|shape1|Input tensor
|Input|in_t*|input2|shape2|Input tensor with the same rank as Input 0
+|Attribute|uint6_t|shift|-|Result right shift (int32 data type only)
|Output|out_t*|output|shape|Output tensor with broadcast shape if necessary
|===
@@ -486,12 +487,17 @@ Elementwise multiplication (Hadamard product) of input tensor 0 and input tensor
[source,c]
----
+assert(in_t==int32_t || shift==0);
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)
- in_t acc = value1 * value2 // takes low bits for int32_t
+ if (shift>0) {
+ out_t acc = apply_scale_32(value1, value2, shift)
+ } else {
+ out_t acc = value1 * value2; // low 32-bits of result for int32_t
+ }
tensor_write<out_t>(output, shape, index, acc)
}
----