[Mlir-commits] [mlir] [mlir][Transforms] Add missing check in applyPermutation (PR #102099)
donald chen
llvmlistbot at llvm.org
Tue Aug 6 06:00:14 PDT 2024
================
@@ -202,6 +202,9 @@ SmallVector<T> applyPermutation(ArrayRef<T> input,
ArrayRef<int64_t> permutation) {
assert(input.size() == permutation.size() &&
"expected input rank to equal permutation rank");
+ assert(
+ llvm::all_of(permutation, [&](size_t s) { return s < input.size(); }) &&
+ "permutation must be within input bounds");
----------------
cxy-1993 wrote:
Top level question: Do we really need to do this check? The permutation itself represents its value range. If there's an error, it should have been caught before the call site. In what scenarios would we need this check?
https://github.com/llvm/llvm-project/pull/102099
More information about the Mlir-commits
mailing list