Skip to content

Commit

Permalink
[mlir][tosa] Ranked check for transpose was wrong.
Browse files Browse the repository at this point in the history
Should have verified the perm length and input rank were the same before
inferring shape. Caused a crash with invalid IR.

Differential Revision: https://reviews.llvm.org/D110674
  • Loading branch information
rsuderman committed Sep 29, 2021
1 parent 1c0e8a9 commit 826d3ea
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
Expand Up @@ -813,12 +813,18 @@ LogicalResult tosa::TransposeOp::inferReturnTypeComponents(

// If input rank and permutation length is unknown, the output rank is
// unknown.
if (!inputShape.hasRank() &&
(!permsShape.hasRank() || permsShape.isDynamicDim(0))) {
if (!inputShape.hasRank() || !permsShape.hasRank() ||
permsShape.isDynamicDim(0)) {
inferredReturnShapes.push_back(ShapedTypeComponents());
return success();
}

// This would imply the number of permutations does not match the rank of the
// input which is illegal.
if (permsShape.getDimSize(0) != inputShape.getRank()) {
return failure();
}

// Without the input dims we cannot determine the output dim sizes but we
// can determine the output rank.
SmallVector<int64_t> outputShape;
Expand Down

0 comments on commit 826d3ea

Please sign in to comment.