[Mlir-commits] [mlir] [TOSA] Prevent OoB accesses in gather/scatter (PR #213242)
Thomas Preud'homme
llvmlistbot at llvm.org
Wed Aug 19 10:52:25 PDT 2026
RoboTux wrote:
> Thanks, makes sense, overall we might want to bring this as a topic to discourse to discuss in more detail. I think I'd prefer making the program crash on OOB accesses. This way it makes the unexpected behaviour explicit. Can `cf.assert` be useful here? I like the idea of gating this behind an optional "hardening" flag.
>
> Though I suspect it's too verbose, I did notice a pass called `generate-runtime-verification` which might be of use here?
As per changed commit message, TOSA 1.0.2 is quite clear that no out of bound memory access is meant to be done by an implementation and thus this is a bug in the lowering. The specification is not as clear for read access but I'm considering that the same reasoning should apply. I have therefore removed the ability to control the behaviour by a flag.
I've looked at existing frameworks to see how they handle this case and most seems to be silent on the matter but I did find tfl.gather_nd and tfl.scatter_nd operators that have defined semantics so decided to match that semantic. If needed it could be changed or the precise behaviour selected via an enum in the future.
https://github.com/llvm/llvm-project/pull/213242
More information about the Mlir-commits
mailing list