diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp --- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp +++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp @@ -1221,17 +1221,19 @@ "applies to only pack or unpack operations"); if (!op || permutation.empty()) return true; - int64_t innerRank = op.getInnerDimsPos().size(); + size_t innerRank = op.getInnerDimsPos().size(); if (outerOrInnerPerm == OuterOrInnerPerm::Inner) return permutation.size() == innerRank && isPermutationVector(permutation); // op.getOuterDimsPerm() may be empty, in which case it is identity. // Don't rely on it. + assert(op.getSourceRank() >= 0); + size_t sourceRank = op.getSourceRank(); if (std::is_same::value) { - return permutation.size() == op.getSourceRank() && - isPermutationVector(permutation); + return permutation.size() == sourceRank && isPermutationVector(permutation); } - return permutation.size() == op.getDestRank() && - isPermutationVector(permutation); + assert(op.getDestRank() >= 0); + size_t destRank = op.getDestRank(); + return permutation.size() == destRank && isPermutationVector(permutation); } /// Return a copy of `tensorType` after permutation by `permutationVector`.