[MLIR] Fix `isValidIndex`

Differential Revision: https://reviews.llvm.org/D100635
This commit is contained in:
Frederik Gossen 2021-04-16 14:58:05 +02:00
parent 9b98497b44
commit c2c65585c5
1 changed files with 2 additions and 1 deletions

View File

@ -353,7 +353,8 @@ bool ElementsAttr::isValidIndex(ArrayRef<uint64_t> index) const {
// Verify that all of the indices are within the shape dimensions. // Verify that all of the indices are within the shape dimensions.
auto shape = type.getShape(); auto shape = type.getShape();
return llvm::all_of(llvm::seq<int>(0, rank), [&](int i) { return llvm::all_of(llvm::seq<int>(0, rank), [&](int i) {
return static_cast<int64_t>(index[i]) < shape[i]; int64_t dim = static_cast<int64_t>(index[i]);
return 0 <= dim && dim < shape[i];
}); });
} }