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.adoc6
1 files changed, 5 insertions, 1 deletions
diff --git a/chapters/ewise_binary.adoc b/chapters/ewise_binary.adoc
index 1a54a99..9265c47 100644
--- a/chapters/ewise_binary.adoc
+++ b/chapters/ewise_binary.adoc
@@ -241,6 +241,8 @@ for_each(index in shape) {
in_t value1 = tensor_read<in_t>(input1, shape1, index1);
in_t value2 = tensor_read<in_t>(input2, shape2, index2);
REQUIRE(value2 != 0);
+ // This catches the case where we divide minimum<in_t> by -1
+ // which is not representable in two's complement
REQUIRE((int64_t)value1 / value2 <= maximum<in_t>);
in_t acc = value1 / value2;
tensor_write<in_t>(output, shape, index, acc);
@@ -668,10 +670,12 @@ None
[source,c++]
----
+REQUIRE(length(table) == TABLE_SIZE);
for_each(index in shape) {
in_t value = tensor_read<in_t>(input, shape, index);
if (in_t == int8_t) {
- out_t acc = table[value];
+ // value is a signed int, convert to a 0 based index
+ out_t acc = table[value + 128];
} else {
out_t acc = apply_lookup(table, value);
}