From c914976c72101774b5aef83ecca497c61dceb0b9 Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Sat, 1 Jun 2019 10:10:24 -0700 Subject: [PATCH] Allow constant of unit type. -- PiperOrigin-RevId: 251053682 --- mlir/lib/StandardOps/Ops.cpp | 3 +++ mlir/test/IR/core-ops.mlir | 3 +++ 2 files changed, 6 insertions(+) diff --git a/mlir/lib/StandardOps/Ops.cpp b/mlir/lib/StandardOps/Ops.cpp index b97c149..da0a48b 100644 --- a/mlir/lib/StandardOps/Ops.cpp +++ b/mlir/lib/StandardOps/Ops.cpp @@ -1121,6 +1121,9 @@ static LogicalResult verify(ConstantOp &op) { return success(); } + if (type.isa() && value.isa()) + return success(); + return op.emitOpError( "requires a result type that aligns with the 'value' attribute"); } diff --git a/mlir/test/IR/core-ops.mlir b/mlir/test/IR/core-ops.mlir index 1a45d9d..5849924 100644 --- a/mlir/test/IR/core-ops.mlir +++ b/mlir/test/IR/core-ops.mlir @@ -282,6 +282,9 @@ func @standard_instrs(tensor<4x4x?xf32>, f32, i32, index) { // CHECK: %{{[0-9]+}} = rank %arg0 : tensor<4x4x?xf32> %72 = rank %t : tensor<4x4x?xf32> + // CHECK: = constant unit + %73 = constant unit + return } -- 2.7.4