From a33441907c67a8ae41af8d4c7923ff013c1e0749 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 5 Oct 2020 08:13:58 -0700 Subject: [PATCH] [MLIR][KernelGen] Add E2E test for `tf.Acos` PiperOrigin-RevId: 335419310 --- .../mhlo/transforms/chlo_legalize_to_hlo_patterns.td | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Dialect/mhlo/transforms/chlo_legalize_to_hlo_patterns.td b/lib/Dialect/mhlo/transforms/chlo_legalize_to_hlo_patterns.td index fb4bf3a..a48abb6 100644 --- a/lib/Dialect/mhlo/transforms/chlo_legalize_to_hlo_patterns.td +++ b/lib/Dialect/mhlo/transforms/chlo_legalize_to_hlo_patterns.td @@ -24,16 +24,17 @@ include "mlir-hlo/Dialect/mhlo/IR/chlo_ops.td" //===----------------------------------------------------------------------===// // Expand acos to MHLO dialect as follows: -// acos(x) = 2 * atan(sqrt(1 - x^2) / (1 + x)) if x != -1 +// acos(x) = 2 * atan2(sqrt(1 - x^2), (1 + x)) if x != -1 // = pi if x == -1 def : Pat<(HLOClient_AcosOp $input), (HLO_SelectOp - (HLO_CompareOp $input, - (HLO_ConstantLike<"0"> $input), + (HLO_CompareOp + $input, + (HLO_ConstantLike<"-1"> $input), HLO_COMPARISON_DIRECTION_NE ), (HLO_MulOp - (HLO_ConstantLike<"2.0f"> $input), + (HLO_ConstantLike<"2"> $input), (HLO_Atan2Op (HLO_SqrtOp (HLO_SubOp @@ -47,7 +48,8 @@ def : Pat<(HLOClient_AcosOp $input), ) ) ), - (HLO_ConstantLike<"M_PI"> $input))>; + (HLO_ConstantLike<"M_PI"> $input) + )>; // Express `atan` as // atan(x) = atan2(x, 1)