fix(compiler): Fix calculation of indexes for result memrefs with non-zero offsets

The function `tensorDataFromMemRef` reading elements from a result
memref and copying them to an instance of `TensorData` fails to handle
memrefs with non-zero offsets as it adds the offset twice when
calculating indexes. This may result in out-of-bounds memory accesses
and incorrect results.

This patch fixes the calculation of indexes by removing the second
addition of the offset.
This commit is contained in:
Andi Drebes
2022-07-26 11:26:13 +02:00
parent 6c2b1addcc
commit fb9066c3e8

View File

@@ -192,7 +192,7 @@ TensorData tensorDataFromMemRef(size_t memref_rank,
// TODO: add a fast path for dense result (no real strides)
for (size_t i = 0; i < len; i++) {
int g_index = offset + global_index(index, sizes, strides, memref_rank);
result.values[i] = aligned[offset + g_index];
result.values[i] = aligned[g_index];
next_coord_index(index, sizes, memref_rank);
}
delete[] index;