From 64b918852c09db6461d4c4c97df288c7b7fee865 Mon Sep 17 00:00:00 2001 From: Tres Popp Date: Tue, 8 Feb 2022 11:15:04 +0100 Subject: [PATCH] Remove restriction on static dimensions in Shape method mlir::shape::ToExtentTensorOp::areCastCompatible didn't allow the input to have a static dimension, but that is allowed. --- mlir/lib/Dialect/Shape/IR/Shape.cpp | 2 +- mlir/test/Dialect/Shape/ops.mlir | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp index 1ae9e68..89a9766 100644 --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -1767,7 +1767,7 @@ bool ToExtentTensorOp::areCastCompatible(TypeRange inputs, TypeRange outputs) { return false; if (auto inputTensor = inputs[0].dyn_cast()) { if (!inputTensor.getElementType().isa() || - inputTensor.getRank() != 1 || !inputTensor.isDynamicDim(0)) + inputTensor.getRank() != 1) return false; } else if (!inputs[0].isa()) { return false; diff --git a/mlir/test/Dialect/Shape/ops.mlir b/mlir/test/Dialect/Shape/ops.mlir index e4f22a2..8c21878 100644 --- a/mlir/test/Dialect/Shape/ops.mlir +++ b/mlir/test/Dialect/Shape/ops.mlir @@ -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) -> !shape.shape { %0 = shape.from_extent_tensor %arg : tensor return %0 : !shape.shape -- 2.7.4