Skip to content

Commit

Permalink
Remove restriction on static dimensions in Shape method
Browse files Browse the repository at this point in the history
mlir::shape::ToExtentTensorOp::areCastCompatible didn't allow the input
to have a static dimension, but that is allowed.
  • Loading branch information
tpopp committed Feb 8, 2022
1 parent 99d9502 commit 64b9188
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Shape/IR/Shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ bool ToExtentTensorOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
return false;
if (auto inputTensor = inputs[0].dyn_cast<RankedTensorType>()) {
if (!inputTensor.getElementType().isa<IndexType>() ||
inputTensor.getRank() != 1 || !inputTensor.isDynamicDim(0))
inputTensor.getRank() != 1)
return false;
} else if (!inputs[0].isa<ShapeType>()) {
return false;
Expand Down
5 changes: 5 additions & 0 deletions mlir/test/Dialect/Shape/ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ func @test_to_extent_tensor(%arg: !shape.shape) -> tensor<3xindex> {
return %0 : tensor<3xindex>
}

func @test_identity_to_extent_tensor(%arg: tensor<3xindex>) -> tensor<3xindex> {
%0 = shape.to_extent_tensor %arg : tensor<3xindex> -> tensor<3xindex>
return %0 : tensor<3xindex>
}

func @test_from_extent_tensor(%arg: tensor<?xindex>) -> !shape.shape {
%0 = shape.from_extent_tensor %arg : tensor<?xindex>
return %0 : !shape.shape
Expand Down

0 comments on commit 64b9188

Please sign in to comment.