Skip to content

Commit 1b703d7

Browse files
fjsyrmiafjankovi
authored andcommitted
[mlir][tosa] Prevent div by 0 in ReshapeOp::inferReturnTypeComponents
1 parent 5dc9e87 commit 1b703d7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mlir/lib/Dialect/Tosa/IR/TosaOps.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,12 @@ LogicalResult tosa::ReshapeOp::inferReturnTypeComponents(
936936

937937
// Determine the length of the dynamic dimension.
938938
for (auto &val : newShapeValue) {
939-
if (ShapedType::isDynamic(val))
939+
if (ShapedType::isDynamic(val)) {
940+
if (staticMul == 0) {
941+
return failure();
942+
}
940943
val = numElements / staticMul;
944+
}
941945
}
942946

943947
inferredReturnShapes.push_back(

0 commit comments

Comments
 (0)