[Mlir-commits] [mlir] [mlir][tosa] Fix not to crash with large permutation indexes (PR #69857)
Jacques Pienaar
llvmlistbot at llvm.org
Sat Oct 21 16:40:19 PDT 2023
================
@@ -966,6 +966,16 @@ LogicalResult tosa::TransposeOp::inferReturnTypeComponents(
if (matchPattern(adaptor.getPerms(), m_Constant(&attr)) &&
attr.getType().getRank() == 1) {
ShapeAdaptor permShape = attr;
+ // Constant permutation must be the same length as the input rank.
+ if (inputShape.getRank() != permShape.getRank())
+ return failure();
+
+ // Constant permutation values must be within the input rank.
+ for (int i = 0; i < inputShape.getRank(); i++) {
----------------
jpienaar wrote:
https://llvm.org/docs/CodingStandards.html#don-t-evaluate-end-every-time-through-a-loop
https://github.com/llvm/llvm-project/pull/69857
More information about the Mlir-commits
mailing list