mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user