[Mlir-commits] [mlir] c2c6558 - [MLIR] Fix `isValidIndex`
Frederik Gossen
llvmlistbot at llvm.org
Fri Apr 16 05:59:19 PDT 2021
Author: Frederik Gossen
Date: 2021-04-16T14:58:54+02:00
New Revision: c2c65585c5e5eb57af2f7cc26bbe9dcf970d1d2f
URL: https://github.com/llvm/llvm-project/commit/c2c65585c5e5eb57af2f7cc26bbe9dcf970d1d2f
DIFF: https://github.com/llvm/llvm-project/commit/c2c65585c5e5eb57af2f7cc26bbe9dcf970d1d2f.diff
LOG: [MLIR] Fix `isValidIndex`
Differential Revision: https://reviews.llvm.org/D100635
Added:
Modified:
mlir/lib/IR/BuiltinAttributes.cpp
Removed:
################################################################################
diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp
index ce6d4b3a603b..d11a9f2465da 100644
--- a/mlir/lib/IR/BuiltinAttributes.cpp
+++ b/mlir/lib/IR/BuiltinAttributes.cpp
@@ -353,7 +353,8 @@ bool ElementsAttr::isValidIndex(ArrayRef<uint64_t> index) const {
// Verify that all of the indices are within the shape dimensions.
auto shape = type.getShape();
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];
});
}
More information about the Mlir-commits
mailing list