[all-commits] [llvm/llvm-project] 8d5c1b: [mlir][CRunnerUtils] Fix iterators accessing MemRe...
Felix Schneider via All-commits
all-commits at lists.llvm.org
Thu Sep 14 04:14:30 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 8d5c1b4562f880a61c9d9a2bddad73f584cdf311
https://github.com/llvm/llvm-project/commit/8d5c1b4562f880a61c9d9a2bddad73f584cdf311
Author: Felix Schneider <fx.schn at gmail.com>
Date: 2023-09-14 (Thu, 14 Sep 2023)
Changed paths:
M mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
M mlir/unittests/ExecutionEngine/CMakeLists.txt
M mlir/unittests/ExecutionEngine/DynamicMemRef.cpp
A mlir/unittests/ExecutionEngine/StridedMemRef.cpp
Log Message:
-----------
[mlir][CRunnerUtils] Fix iterators accessing MemRefs with non-zero offset
MemRef descriptors contain - among others - a field called `alignedPtr` or `data` and a field called `offset`. The actual buffer of the MemRef starts at `offset` elements after `alignedPtr`. In the CRunnerUtils, there exist helper classes to iterate over MemRefs' elements but the `offset` is not handled consistently so that accessing a MemRef with an `offset` != 0 via an iterator will lead to incorrect results.
The problem is that "offset" can be understood in two ways, firstly as the offset of the beginning of the MemRef with respect to the `alignedPtr`, ie what the `offset` field means in the MemRef descriptor, and secondly as the offset of some element within the MemRef relative to the first element of the MemRef, which could more accurately be called something like `linearIndex`.
The `offset` field within `StridedMemRefIterator` and `DynamicMemRefIterator` are interpreted the first way, therefore the offsets passed to the constructors of these classes need to account for the already existing offset in the descriptor on top of any potential "shift" within the MemRef.
This patch takes care of that and adds some basic tests that catch problems with indexing MemRefs with an `offset`.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D157008
More information about the All-commits
mailing list