Lowering for mhlo.ceil to std.ceil

PiperOrigin-RevId: 326335301
This commit is contained in:
Robert Suderman 2020-08-12 16:14:42 -07:00 committed by TensorFlow MLIR Team
parent ec328ae43b
commit 5252aeae8f
2 changed files with 13 additions and 0 deletions

View File

@ -36,6 +36,10 @@ def IsSameSizePred : CPred<
def IsSameSizeConstraint : Constraint<IsSameSizePred, "inputs are same size">; def IsSameSizeConstraint : Constraint<IsSameSizePred, "inputs are same size">;
// Unary Lowering Patterns.
def : Pat<(HLO_CeilOp HLO_FpTensor:$i), (CeilFOp $i)>;
// Binary Lowering Patterns.
def : Pat<(HLO_AndOp HLO_PredTensor:$l, HLO_PredTensor:$r), def : Pat<(HLO_AndOp HLO_PredTensor:$l, HLO_PredTensor:$r),
(AndOp $l, $r), (AndOp $l, $r),
[(IsSameSizeConstraint $l, $r)]>; [(IsSameSizeConstraint $l, $r)]>;

View File

@ -42,6 +42,15 @@ func @binary_ops_int(%arg0: tensor<4xi32>, %arg1: tensor<4xi32>) -> tensor<4xi32
return %4 : tensor<4xi32> return %4 : tensor<4xi32>
} }
// CHECK-LABEL: func @unary_ops_float
func @unary_ops_float(%arg0: tensor<4xf32>) -> tensor<4xf32> {
// CHECK-NEXT: %0 = ceilf %arg0 : tensor<4xf32>
%0 = "mhlo.ceil"(%arg0) : (tensor<4xf32>) -> tensor<4xf32>
// CHECK-NEXT: return %0 : tensor<4xf32>
return %0 : tensor<4xf32>
}
// CHECK-LABEL: func @compare_int(%arg0: tensor<4xi32>) -> (tensor<4xi1>, tensor<4xi1>, tensor<4xi1>, tensor<4xi1>, tensor<4xi1>, tensor<4xi1>) { // CHECK-LABEL: func @compare_int(%arg0: tensor<4xi32>) -> (tensor<4xi1>, tensor<4xi1>, tensor<4xi1>, tensor<4xi1>, tensor<4xi1>, tensor<4xi1>) {
func @compare_int(%arg0: tensor<4xi32>) -> (tensor<4xi1>,tensor<4xi1>,tensor<4xi1>,tensor<4xi1>,tensor<4xi1>,tensor<4xi1>) { func @compare_int(%arg0: tensor<4xi32>) -> (tensor<4xi1>,tensor<4xi1>,tensor<4xi1>,tensor<4xi1>,tensor<4xi1>,tensor<4xi1>) {
// CHECK-NEXT: %0 = cmpi "eq", %arg0, %arg0 : tensor<4xi32> // CHECK-NEXT: %0 = cmpi "eq", %arg0, %arg0 : tensor<4xi32>