Skip to content

Commit c1068ec

Browse files
committed
[mlir] Allow all shaped types for arith ops.
1 parent 9ddfe62 commit c1068ec

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

mlir/include/mlir/IR/CommonTypeConstraints.td

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,10 @@ def AnyScalableVector : ScalableVectorOf<[AnyType]>;
636636

637637
// Shaped types.
638638

639+
class ShapedTypeOf<list<Type> allowedTypes> :
640+
ShapedContainerType<allowedTypes, IsShapedTypePred, "shaped",
641+
"::mlir::ShapedType">;
642+
639643
def AnyShaped: ShapedContainerType<[AnyType], IsShapedTypePred, "shaped",
640644
"::mlir::ShapedType">;
641645

@@ -844,8 +848,7 @@ class NestedTupleOf<list<Type> allowedTypes> :
844848
// Type constraint for types that are "like" some type or set of types T, that is
845849
// they're either a T, a vector of Ts, or a tensor of Ts
846850
class TypeOrContainer<Type allowedType, string name> : TypeConstraint<Or<[
847-
allowedType.predicate, VectorOf<[allowedType]>.predicate,
848-
TensorOf<[allowedType]>.predicate]>,
851+
allowedType.predicate, ShapedTypeOf<[allowedType]>.predicate]>,
849852
name>;
850853

851854
// Temporary constraint to allow gradual transition to supporting 0-D vectors.

mlir/test/Dialect/Arith/ops.mlir

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ func.func @test_addi_tensor(%arg0 : tensor<8x8xi64>, %arg1 : tensor<8x8xi64>) ->
1313
return %0 : tensor<8x8xi64>
1414
}
1515

16+
// CHECK-LABEL: test_addi_unranked_tensor
17+
func.func @test_addi_unranked_tensor(%arg0 : tensor<*xi32>, %arg1 : tensor<*xi32>) -> tensor<*xi32> {
18+
%0 = arith.addi %arg0, %arg1 : tensor<*xi32>
19+
return %0 : tensor<*xi32>
20+
}
21+
1622
// CHECK-LABEL: test_addi_vector
1723
func.func @test_addi_vector(%arg0 : vector<8xi64>, %arg1 : vector<8xi64>) -> vector<8xi64> {
1824
%0 = arith.addi %arg0, %arg1 : vector<8xi64>

0 commit comments

Comments
 (0)