Allow constant of unit type.
authorJacques Pienaar <jpienaar@google.com>
Sat, 1 Jun 2019 17:10:24 +0000 (10:10 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sun, 2 Jun 2019 03:14:48 +0000 (20:14 -0700)
--

PiperOrigin-RevId: 251053682

mlir/lib/StandardOps/Ops.cpp
mlir/test/IR/core-ops.mlir

index b97c149..da0a48b 100644 (file)
@@ -1121,6 +1121,9 @@ static LogicalResult verify(ConstantOp &op) {
     return success();
   }
 
+  if (type.isa<NoneType>() && value.isa<UnitAttr>())
+    return success();
+
   return op.emitOpError(
       "requires a result type that aligns with the 'value' attribute");
 }
index 1a45d9d..5849924 100644 (file)
@@ -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
 }