diff --git a/build_tools/math/README.md b/build_tools/math/README.md index 8e3a8f180d..697d562ebd 100644 --- a/build_tools/math/README.md +++ b/build_tools/math/README.md @@ -31,7 +31,7 @@ following requirements: - Python 3.11 or newer - mpmath 1.3 or newer -- functional_algorithms 0.11.1 or newer +- functional_algorithms 0.12 or newer that can be installed via pypi: diff --git a/build_tools/math/generate_ChloDecompositionPatternsMath.py b/build_tools/math/generate_ChloDecompositionPatternsMath.py index 885849ce89..9283d60618 100644 --- a/build_tools/math/generate_ChloDecompositionPatternsMath.py +++ b/build_tools/math/generate_ChloDecompositionPatternsMath.py @@ -98,6 +98,7 @@ def main(): ("CHLO_AtanhOp", "complex_atanh", ("z:complex",)), ("CHLO_SquareOp", "complex_square", ("z:complex",)), ("CHLO_SquareOp", "real_square", ("x:float",)), + ("CHLO_Log1pOp", "complex_log1p", ("z:complex",)), ]: print(f'Generating {chloname} from {fname}{args}') func = getattr(fa.algorithms, fname, None) diff --git a/build_tools/math/generate_tests.py b/build_tools/math/generate_tests.py index ecd413cda2..1e3e267f58 100644 --- a/build_tools/math/generate_tests.py +++ b/build_tools/math/generate_tests.py @@ -64,6 +64,7 @@ dict(name="acosh", mpmath_name="arccosh"), dict(name="atanh", mpmath_name="arctanh"), dict(name="square", mpmath_name="square"), + dict(name="log1p", mpmath_name="log1p"), ] diff --git a/stablehlo/dialect/ChloOps.cpp b/stablehlo/dialect/ChloOps.cpp index 1868204647..d13d94ae2c 100644 --- a/stablehlo/dialect/ChloOps.cpp +++ b/stablehlo/dialect/ChloOps.cpp @@ -87,6 +87,7 @@ INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(ErfOp) INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(ErfcOp) INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(ErfInvOp) INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(LgammaOp) +INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(Log1pOp) INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(NextAfterOp) INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(PolygammaOp) INFER_RETURN_TYPE_COMPONENTS_FROM_OPERANDS(SinhOp) diff --git a/stablehlo/dialect/ChloOps.td b/stablehlo/dialect/ChloOps.td index 77ed7b5493..e96e19e1e4 100644 --- a/stablehlo/dialect/ChloOps.td +++ b/stablehlo/dialect/ChloOps.td @@ -747,6 +747,20 @@ def CHLO_LgammaOp : CHLO_UnaryElementwiseOp<"lgamma", }]; } +def CHLO_Log1pOp : CHLO_UnaryElementwiseOp<"log1p", + [HLO_CompatibleOperandsAndResultType], HLO_AnyFpOrComplexTensor> { + let summary = "Log1p function"; + + let description = [{ + Returns `Log1p(operand)` element-wise. + + $$ + \log1p(x) = complex(log(hypot(x.real + 1, x.imag)), arctan2(x.imag, x.real + 1)) if x is a complex number + = log(x + 1) otherwise + $$ + }]; +} + def CHLO_SquareOp : CHLO_UnaryElementwiseOp<"square", [HLO_CompatibleOperandsAndResultType], HLO_AnyFpOrComplexTensor> { let summary = "Square operation"; diff --git a/stablehlo/tests/chlo/chlo_legalize_to_stablehlo.mlir b/stablehlo/tests/chlo/chlo_legalize_to_stablehlo.mlir index 713f62f3ff..f92032189c 100644 --- a/stablehlo/tests/chlo/chlo_legalize_to_stablehlo.mlir +++ b/stablehlo/tests/chlo/chlo_legalize_to_stablehlo.mlir @@ -3925,3 +3925,122 @@ func.func @square_f32(%arg : tensor) -> tensor { %result = "chlo.square"(%arg) : (tensor) -> tensor func.return %result : tensor } + +// CHECK-LABEL: @log1p_complex_f32( +// CHECK-SAME: %[[VAL_0:.*]]: tensor>) -> tensor> { +// CHECK: %[[VAL_1:.*]] = stablehlo.real %[[VAL_0]] : (tensor>) -> tensor +// CHECK: %[[VAL_2:.*]] = stablehlo.abs %[[VAL_1]] : tensor +// CHECK: %[[VAL_3:.*]] = stablehlo.imag %[[VAL_0]] : (tensor>) -> tensor +// CHECK: %[[VAL_4:.*]] = stablehlo.abs %[[VAL_3]] : tensor +// CHECK: %[[VAL_5:.*]] = stablehlo.maximum %[[VAL_2]], %[[VAL_4]] : tensor +// CHECK: %[[VAL_6:.*]] = stablehlo.constant dense<3.40282347E+38> : tensor +// CHECK: %[[VAL_7:.*]] = stablehlo.sqrt %[[VAL_6]] : tensor +// CHECK: %[[VAL_8:.*]] = stablehlo.constant dense<0.00999999977> : tensor +// CHECK: %[[VAL_9:.*]] = stablehlo.multiply %[[VAL_7]], %[[VAL_8]] : tensor +// CHECK: %[[VAL_10:.*]] = stablehlo.compare GT, %[[VAL_5]], %[[VAL_9]] : (tensor, tensor) -> tensor +// CHECK: %[[VAL_11:.*]] = stablehlo.log %[[VAL_5]] : tensor +// CHECK: %[[VAL_12:.*]] = stablehlo.constant dense<5.000000e-01> : tensor +// CHECK: %[[VAL_13:.*]] = stablehlo.minimum %[[VAL_2]], %[[VAL_4]] : tensor +// CHECK: %[[VAL_14:.*]] = stablehlo.compare EQ, %[[VAL_13]], %[[VAL_5]] : (tensor, tensor) -> tensor +// CHECK: %[[VAL_15:.*]] = stablehlo.constant dense<1.000000e+00> : tensor +// CHECK: %[[VAL_16:.*]] = stablehlo.divide %[[VAL_13]], %[[VAL_5]] : tensor +// CHECK: %[[VAL_17:.*]] = stablehlo.multiply %[[VAL_16]], %[[VAL_16]] : tensor +// CHECK: %[[VAL_18:.*]] = stablehlo.select %[[VAL_14]], %[[VAL_15]], %[[VAL_17]] : tensor, tensor +// CHECK: %[[VAL_19:.*]] = stablehlo.log_plus_one %[[VAL_18]] : tensor +// CHECK: %[[VAL_20:.*]] = stablehlo.multiply %[[VAL_12]], %[[VAL_19]] : tensor +// CHECK: %[[VAL_21:.*]] = stablehlo.add %[[VAL_11]], %[[VAL_20]] : tensor +// CHECK: %[[VAL_22:.*]] = stablehlo.add %[[VAL_1]], %[[VAL_15]] : tensor +// CHECK: %[[VAL_23:.*]] = stablehlo.abs %[[VAL_22]] : tensor +// CHECK: %[[VAL_24:.*]] = stablehlo.add %[[VAL_23]], %[[VAL_4]] : tensor +// CHECK: %[[VAL_25:.*]] = stablehlo.constant dense<2.000000e-01> : tensor +// CHECK: %[[VAL_26:.*]] = stablehlo.compare LT, %[[VAL_24]], %[[VAL_25]] : (tensor, tensor) -> tensor +// CHECK: %[[VAL_27:.*]] = stablehlo.multiply %[[VAL_22]], %[[VAL_22]] : tensor +// CHECK: %[[VAL_28:.*]] = stablehlo.multiply %[[VAL_3]], %[[VAL_3]] : tensor +// CHECK: %[[VAL_29:.*]] = stablehlo.add %[[VAL_27]], %[[VAL_28]] : tensor +// CHECK: %[[VAL_30:.*]] = stablehlo.log %[[VAL_29]] : tensor +// CHECK: %[[VAL_31:.*]] = stablehlo.multiply %[[VAL_12]], %[[VAL_30]] : tensor +// CHECK: %[[VAL_32:.*]] = stablehlo.add %[[VAL_1]], %[[VAL_1]] : tensor +// CHECK: %[[VAL_33:.*]] = stablehlo.add %[[VAL_32]], %[[VAL_28]] : tensor +// CHECK: %[[VAL_34:.*]] = stablehlo.multiply %[[VAL_1]], %[[VAL_1]] : tensor +// CHECK: %[[VAL_35:.*]] = stablehlo.add %[[VAL_33]], %[[VAL_34]] : tensor +// CHECK: %[[VAL_36:.*]] = stablehlo.negate %[[VAL_28]] : tensor +// CHECK: %[[VAL_37:.*]] = stablehlo.constant dense<0x7F800000> : tensor +// CHECK: %[[VAL_38:.*]] = stablehlo.compare GT, %[[VAL_6]], %[[VAL_37]] : (tensor, tensor) -> tensor +// CHECK: %[[VAL_39:.*]] = stablehlo.constant dense<0x4D000000> : tensor +// CHECK: %[[VAL_40:.*]] = stablehlo.constant dense<9.99999968E+37> : tensor +// CHECK: %[[VAL_41:.*]] = stablehlo.compare GT, %[[VAL_6]], %[[VAL_40]] : (tensor, tensor) -> tensor +// CHECK: %[[VAL_42:.*]] = stablehlo.constant dense<4.097000e+03> : tensor +// CHECK: %[[VAL_43:.*]] = stablehlo.constant dense<6.500000e+01> : tensor +// CHECK: %[[VAL_44:.*]] = stablehlo.select %[[VAL_41]], %[[VAL_42]], %[[VAL_43]] : tensor, tensor +// CHECK: %[[VAL_45:.*]] = stablehlo.select %[[VAL_38]], %[[VAL_39]], %[[VAL_44]] : tensor, tensor +// CHECK: %[[VAL_46:.*]] = stablehlo.multiply %[[VAL_45]], %[[VAL_3]] : tensor +// CHECK: %[[VAL_47:.*]] = stablehlo.subtract %[[VAL_3]], %[[VAL_46]] : tensor +// CHECK: %[[VAL_48:.*]] = stablehlo.add %[[VAL_46]], %[[VAL_47]] : tensor +// CHECK: %[[VAL_49:.*]] = stablehlo.multiply %[[VAL_48]], %[[VAL_48]] : tensor +// CHECK: %[[VAL_50:.*]] = stablehlo.add %[[VAL_36]], %[[VAL_49]] : tensor +// CHECK: %[[VAL_51:.*]] = stablehlo.subtract %[[VAL_3]], %[[VAL_48]] : tensor +// CHECK: %[[VAL_52:.*]] = stablehlo.multiply %[[VAL_48]], %[[VAL_51]] : tensor +// CHECK: %[[VAL_53:.*]] = stablehlo.add %[[VAL_50]], %[[VAL_52]] : tensor +// CHECK: %[[VAL_54:.*]] = stablehlo.add %[[VAL_53]], %[[VAL_52]] : tensor +// CHECK: %[[VAL_55:.*]] = stablehlo.multiply %[[VAL_51]], %[[VAL_51]] : tensor +// CHECK: %[[VAL_56:.*]] = stablehlo.add %[[VAL_54]], %[[VAL_55]] : tensor +// CHECK: %[[VAL_57:.*]] = stablehlo.add %[[VAL_35]], %[[VAL_56]] : tensor +// CHECK: %[[VAL_58:.*]] = stablehlo.negate %[[VAL_34]] : tensor +// CHECK: %[[VAL_59:.*]] = stablehlo.multiply %[[VAL_45]], %[[VAL_1]] : tensor +// CHECK: %[[VAL_60:.*]] = stablehlo.subtract %[[VAL_1]], %[[VAL_59]] : tensor +// CHECK: %[[VAL_61:.*]] = stablehlo.add %[[VAL_59]], %[[VAL_60]] : tensor +// CHECK: %[[VAL_62:.*]] = stablehlo.multiply %[[VAL_61]], %[[VAL_61]] : tensor +// CHECK: %[[VAL_63:.*]] = stablehlo.add %[[VAL_58]], %[[VAL_62]] : tensor +// CHECK: %[[VAL_64:.*]] = stablehlo.subtract %[[VAL_1]], %[[VAL_61]] : tensor +// CHECK: %[[VAL_65:.*]] = stablehlo.multiply %[[VAL_61]], %[[VAL_64]] : tensor +// CHECK: %[[VAL_66:.*]] = stablehlo.add %[[VAL_63]], %[[VAL_65]] : tensor +// CHECK: %[[VAL_67:.*]] = stablehlo.add %[[VAL_66]], %[[VAL_65]] : tensor +// CHECK: %[[VAL_68:.*]] = stablehlo.multiply %[[VAL_64]], %[[VAL_64]] : tensor +// CHECK: %[[VAL_69:.*]] = stablehlo.add %[[VAL_67]], %[[VAL_68]] : tensor +// CHECK: %[[VAL_70:.*]] = stablehlo.add %[[VAL_57]], %[[VAL_69]] : tensor +// CHECK: %[[VAL_71:.*]] = stablehlo.subtract %[[VAL_33]], %[[VAL_32]] : tensor +// CHECK: %[[VAL_72:.*]] = stablehlo.subtract %[[VAL_33]], %[[VAL_71]] : tensor +// CHECK: %[[VAL_73:.*]] = stablehlo.subtract %[[VAL_32]], %[[VAL_72]] : tensor +// CHECK: %[[VAL_74:.*]] = stablehlo.subtract %[[VAL_28]], %[[VAL_71]] : tensor +// CHECK: %[[VAL_75:.*]] = stablehlo.add %[[VAL_73]], %[[VAL_74]] : tensor +// CHECK: %[[VAL_76:.*]] = stablehlo.subtract %[[VAL_35]], %[[VAL_33]] : tensor +// CHECK: %[[VAL_77:.*]] = stablehlo.subtract %[[VAL_35]], %[[VAL_76]] : tensor +// CHECK: %[[VAL_78:.*]] = stablehlo.subtract %[[VAL_33]], %[[VAL_77]] : tensor +// CHECK: %[[VAL_79:.*]] = stablehlo.subtract %[[VAL_34]], %[[VAL_76]] : tensor +// CHECK: %[[VAL_80:.*]] = stablehlo.add %[[VAL_78]], %[[VAL_79]] : tensor +// CHECK: %[[VAL_81:.*]] = stablehlo.add %[[VAL_75]], %[[VAL_80]] : tensor +// CHECK: %[[VAL_82:.*]] = stablehlo.subtract %[[VAL_57]], %[[VAL_35]] : tensor +// CHECK: %[[VAL_83:.*]] = stablehlo.subtract %[[VAL_57]], %[[VAL_82]] : tensor +// CHECK: %[[VAL_84:.*]] = stablehlo.subtract %[[VAL_35]], %[[VAL_83]] : tensor +// CHECK: %[[VAL_85:.*]] = stablehlo.subtract %[[VAL_56]], %[[VAL_82]] : tensor +// CHECK: %[[VAL_86:.*]] = stablehlo.add %[[VAL_84]], %[[VAL_85]] : tensor +// CHECK: %[[VAL_87:.*]] = stablehlo.add %[[VAL_81]], %[[VAL_86]] : tensor +// CHECK: %[[VAL_88:.*]] = stablehlo.subtract %[[VAL_70]], %[[VAL_57]] : tensor +// CHECK: %[[VAL_89:.*]] = stablehlo.subtract %[[VAL_70]], %[[VAL_88]] : tensor +// CHECK: %[[VAL_90:.*]] = stablehlo.subtract %[[VAL_57]], %[[VAL_89]] : tensor +// CHECK: %[[VAL_91:.*]] = stablehlo.subtract %[[VAL_69]], %[[VAL_88]] : tensor +// CHECK: %[[VAL_92:.*]] = stablehlo.add %[[VAL_90]], %[[VAL_91]] : tensor +// CHECK: %[[VAL_93:.*]] = stablehlo.add %[[VAL_87]], %[[VAL_92]] : tensor +// CHECK: %[[VAL_94:.*]] = stablehlo.add %[[VAL_70]], %[[VAL_93]] : tensor +// CHECK: %[[VAL_95:.*]] = stablehlo.log_plus_one %[[VAL_94]] : tensor +// CHECK: %[[VAL_96:.*]] = stablehlo.multiply %[[VAL_12]], %[[VAL_95]] : tensor +// CHECK: %[[VAL_97:.*]] = stablehlo.select %[[VAL_26]], %[[VAL_31]], %[[VAL_96]] : tensor, tensor +// CHECK: %[[VAL_98:.*]] = stablehlo.select %[[VAL_10]], %[[VAL_21]], %[[VAL_97]] : tensor, tensor +// CHECK: %[[VAL_99:.*]] = stablehlo.atan2 %[[VAL_3]], %[[VAL_22]] : tensor +// CHECK: %[[VAL_100:.*]] = stablehlo.complex %[[VAL_98]], %[[VAL_99]] : tensor> +// CHECK: return %[[VAL_100]] : tensor> +// CHECK: } +func.func @log1p_complex_f32(%arg : tensor>) -> tensor> { + %result = "chlo.log1p"(%arg) : (tensor>) -> tensor> + func.return %result : tensor> +} + +// CHECK-LABEL: @log1p_f32( +// CHECK-SAME: %[[VAL_0:.*]]: tensor) -> tensor { +// CHECK: %[[VAL_1:.*]] = stablehlo.log_plus_one %[[VAL_0]] : tensor +// CHECK: return %[[VAL_1]] : tensor +// CHECK: } +func.func @log1p_f32(%arg : tensor) -> tensor { + %result = "chlo.log1p"(%arg) : (tensor) -> tensor + func.return %result : tensor +} diff --git a/stablehlo/tests/math/log1p_complex128.mlir b/stablehlo/tests/math/log1p_complex128.mlir new file mode 100644 index 0000000000..5b607eaaf3 --- /dev/null +++ b/stablehlo/tests/math/log1p_complex128.mlir @@ -0,0 +1,19 @@ +// RUN: stablehlo-opt --chlo-legalize-to-stablehlo %s | stablehlo-translate --interpret +// This file is generated, see build_tools/math/README.md for more information. +module @log1p_complex128 { + func.func private @samples() -> tensor<203xcomplex> { + %0 = stablehlo.constant dense<"0x000000000000F0FF000000000000F0FFFFFFFFFFFFFFEFFF000000000000F0FFFEFFFFFFFFFFEFFF000000000000F0FF000000000000F8BF000000000000F0FF000000000000FC9F000000000000F0FF0100000000000080000000000000F0FF0000000000000000000000000000F0FF0100000000000000000000000000F0FF000000000000FC1F000000000000F0FF000000000000F83F000000000000F0FFFEFFFFFFFFFFEF7F000000000000F0FFFFFFFFFFFFFFEF7F000000000000F0FF000000000000F07F000000000000F0FF000000000000F0FFFFFFFFFFFFFFEFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFEFFFFEFFFFFFFFFFEFFFFFFFFFFFFFFFEFFF000000000000F8BFFFFFFFFFFFFFEFFF000000000000FC9FFFFFFFFFFFFFEFFF0100000000000080FFFFFFFFFFFFEFFF0000000000000000FFFFFFFFFFFFEFFF0100000000000000FFFFFFFFFFFFEFFF000000000000FC1FFFFFFFFFFFFFEFFF000000000000F83FFFFFFFFFFFFFEFFFFEFFFFFFFFFFEF7FFFFFFFFFFFFFEFFFFFFFFFFFFFFFEF7FFFFFFFFFFFFFEFFF000000000000F07FFFFFFFFFFFFFEFFF000000000000F0FFFEFFFFFFFFFFEFFFFFFFFFFFFFFFEFFFFEFFFFFFFFFFEFFFFEFFFFFFFFFFEFFFFEFFFFFFFFFFEFFF000000000000F8BFFEFFFFFFFFFFEFFF000000000000FC9FFEFFFFFFFFFFEFFF0100000000000080FEFFFFFFFFFFEFFF0000000000000000FEFFFFFFFFFFEFFF0100000000000000FEFFFFFFFFFFEFFF000000000000FC1FFEFFFFFFFFFFEFFF000000000000F83FFEFFFFFFFFFFEFFFFEFFFFFFFFFFEF7FFEFFFFFFFFFFEFFFFFFFFFFFFFFFEF7FFEFFFFFFFFFFEFFF000000000000F07FFEFFFFFFFFFFEFFF000000000000F0FF000000000000F8BFFFFFFFFFFFFFEFFF000000000000F8BFFEFFFFFFFFFFEFFF000000000000F8BF000000000000F8BF000000000000F8BF000000000000FC9F000000000000F8BF0100000000000080000000000000F8BF0000000000000000000000000000F8BF0100000000000000000000000000F8BF000000000000FC1F000000000000F8BF000000000000F83F000000000000F8BFFEFFFFFFFFFFEF7F000000000000F8BFFFFFFFFFFFFFEF7F000000000000F8BF000000000000F07F000000000000F8BF000000000000F0FF000000000000FC9FFFFFFFFFFFFFEFFF000000000000FC9FFEFFFFFFFFFFEFFF000000000000FC9F000000000000F8BF000000000000FC9F000000000000FC9F000000000000FC9F0100000000000080000000000000FC9F0000000000000000000000000000FC9F0100000000000000000000000000FC9F000000000000FC1F000000000000FC9F000000000000F83F000000000000FC9FFEFFFFFFFFFFEF7F000000000000FC9FFFFFFFFFFFFFEF7F000000000000FC9F000000000000F07F000000000000FC9F000000000000F0FF0100000000000080FFFFFFFFFFFFEFFF0100000000000080FEFFFFFFFFFFEFFF0100000000000080000000000000F8BF0100000000000080000000000000FC9F0100000000000080010000000000008001000000000000800000000000000000010000000000008001000000000000000100000000000080000000000000FC1F0100000000000080000000000000F83F0100000000000080FEFFFFFFFFFFEF7F0100000000000080FFFFFFFFFFFFEF7F0100000000000080000000000000F07F0100000000000080000000000000F0FF0000000000000000FFFFFFFFFFFFEFFF0000000000000000FEFFFFFFFFFFEFFF0000000000000000000000000000F8BF0000000000000000000000000000FC9F0000000000000000010000000000008000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000FC1F0000000000000000000000000000F83F0000000000000000FEFFFFFFFFFFEF7F0000000000000000FFFFFFFFFFFFEF7F0000000000000000000000000000F07F0000000000000000000000000000F0FF0100000000000000FFFFFFFFFFFFEFFF0100000000000000FEFFFFFFFFFFEFFF0100000000000000000000000000F8BF0100000000000000000000000000FC9F0100000000000000010000000000008001000000000000000000000000000000010000000000000001000000000000000100000000000000000000000000FC1F0100000000000000000000000000F83F0100000000000000FEFFFFFFFFFFEF7F0100000000000000FFFFFFFFFFFFEF7F0100000000000000000000000000F07F0100000000000000000000000000F0FF000000000000FC1FFFFFFFFFFFFFEFFF000000000000FC1FFEFFFFFFFFFFEFFF000000000000FC1F000000000000F8BF000000000000FC1F000000000000FC9F000000000000FC1F0100000000000080000000000000FC1F0000000000000000000000000000FC1F0100000000000000000000000000FC1F000000000000FC1F000000000000FC1F000000000000F83F000000000000FC1FFEFFFFFFFFFFEF7F000000000000FC1FFFFFFFFFFFFFEF7F000000000000FC1F000000000000F07F000000000000FC1F000000000000F0FF000000000000F83FFFFFFFFFFFFFEFFF000000000000F83FFEFFFFFFFFFFEFFF000000000000F83F000000000000F8BF000000000000F83F000000000000FC9F000000000000F83F0100000000000080000000000000F83F0000000000000000000000000000F83F0100000000000000000000000000F83F000000000000FC1F000000000000F83F000000000000F83F000000000000F83FFEFFFFFFFFFFEF7F000000000000F83FFFFFFFFFFFFFEF7F000000000000F83F000000000000F07F000000000000F83F000000000000F0FFFEFFFFFFFFFFEF7FFFFFFFFFFFFFEFFFFEFFFFFFFFFFEF7FFEFFFFFFFFFFEFFFFEFFFFFFFFFFEF7F000000000000F8BFFEFFFFFFFFFFEF7F000000000000FC9FFEFFFFFFFFFFEF7F0100000000000080FEFFFFFFFFFFEF7F0000000000000000FEFFFFFFFFFFEF7F0100000000000000FEFFFFFFFFFFEF7F000000000000FC1FFEFFFFFFFFFFEF7F000000000000F83FFEFFFFFFFFFFEF7FFEFFFFFFFFFFEF7FFEFFFFFFFFFFEF7FFFFFFFFFFFFFEF7FFEFFFFFFFFFFEF7F000000000000F07FFEFFFFFFFFFFEF7F000000000000F0FFFFFFFFFFFFFFEF7FFFFFFFFFFFFFEFFFFFFFFFFFFFFFEF7FFEFFFFFFFFFFEFFFFFFFFFFFFFFFEF7F000000000000F8BFFFFFFFFFFFFFEF7F000000000000FC9FFFFFFFFFFFFFEF7F0100000000000080FFFFFFFFFFFFEF7F0000000000000000FFFFFFFFFFFFEF7F0100000000000000FFFFFFFFFFFFEF7F000000000000FC1FFFFFFFFFFFFFEF7F000000000000F83FFFFFFFFFFFFFEF7FFEFFFFFFFFFFEF7FFFFFFFFFFFFFEF7FFFFFFFFFFFFFEF7FFFFFFFFFFFFFEF7F000000000000F07FFFFFFFFFFFFFEF7F000000000000F0FF000000000000F07FFFFFFFFFFFFFEFFF000000000000F07FFEFFFFFFFFFFEFFF000000000000F07F000000000000F8BF000000000000F07F000000000000FC9F000000000000F07F0100000000000080000000000000F07F0000000000000000000000000000F07F0100000000000000000000000000F07F000000000000FC1F000000000000F07F000000000000F83F000000000000F07FFEFFFFFFFFFFEF7F000000000000F07FFFFFFFFFFFFFEF7F000000000000F07F000000000000F07F000000000000F07FBD89D897B2D28CBC3A8C30E28E79453EBE89D897B2D28CBC3A8C30E28E79453EBC89D897B2D28CBC3A8C30E28E79453E9A2BA1869B84F6BC48AFBC9AF2D77A3E9B2BA1869B84F6BC48AFBC9AF2D77A3E992BA1869B84F6BC48AFBC9AF2D77A3E11EA2D81999761BD8DEDB5A0F7C6B03E12EA2D81999761BD8DEDB5A0F7C6B03E10EA2D81999761BD8DEDB5A0F7C6B03EB9BDD7D9DF7CCBBDF068E388B5F8E43EBABDD7D9DF7CCBBDF068E388B5F8E43EB8BDD7D9DF7CCBBDF068E388B5F8E43E398C30E28E7935BE2C431CEBE2361A3F3A8C30E28E7935BE2C431CEBE2361A3F388C30E28E7935BE2C431CEBE2361A3F8DEDB5A0F7C6A0BEFCA9F1D24D62503F8EEDB5A0F7C6A0BEFCA9F1D24D62503F8CEDB5A0F7C6A0BEFCA9F1D24D62503F2D431CEBE2360ABF7B14AE47E17A843F2E431CEBE2360ABF7B14AE47E17A843F2C431CEBE2360ABF7B14AE47E17A843F7A14AE47E17A74BF999999999999B93F7B14AE47E17A74BF999999999999B93F7914AE47E17A74BF999999999999B93F000000000000E0BF000000000000F03F010000000000E0BF000000000000F03FFFFFFFFFFFFFDFBF000000000000F03F00000000000049C00000000000002440FFFFFFFFFFFF48C00000000000002440FFFFFFFFFFFF48C00000000000002440000000000088B3C00000000000005940FFFFFFFFFF87B3C00000000000005940FFFFFFFFFF87B3C00000000000005940C7B96EC64009CFBF002BD1A3F36BDFBF"> : tensor<203xcomplex> + return %0 : tensor<203xcomplex> + } + func.func private @expected() -> tensor<203xcomplex> { + %0 = stablehlo.constant dense<"0x000000000000F07FD221337F7CD902C0000000000000F07F182D4454FB21F9BF000000000000F07F182D4454FB21F9BF000000000000F07F182D4454FB21F9BF000000000000F07F182D4454FB21F9BF000000000000F07F182D4454FB21F9BF000000000000F07F182D4454FB21F9BF000000000000F07F182D4454FB21F9BF000000000000F07F182D4454FB21F9BF000000000000F07F182D4454FB21F9BF000000000000F07F182D4454FB21F9BF000000000000F07F182D4454FB21F9BF000000000000F07F182D4454FB21E9BF000000000000F07F182D4454FB2109C036195AC708318640D221337F7CD902C036195AC708318640D221337F7CD902C0EF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BF36195AC708318640192D4454FB21E9BF36195AC708318640182D4454FB21E9BF000000000000F07F0000000000000000000000000000F07F182D4454FB2109C036195AC708318640D221337F7CD902C036195AC708318640D221337F7CD902C0EF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BFEF39FAFE422E8640182D4454FB21F9BF36195AC708318640182D4454FB21E9BF36195AC708318640182D4454FB21E9BF000000000000F07F0000000000000000000000000000F07F182D4454FB2109C0EF39FAFE422E8640182D4454FB2109C0EF39FAFE422E8640182D4454FB2109C078E0E0F04052DD3FD1D40D3DDF47FEBFB3DE6857C5DBE23F9BF681D20B73EFBFB3DE6857C5DBE23F9BF681D20B73EFBFB3DE6857C5DBE23F9BF681D20B73EFBFB3DE6857C5DBE23F9BF681D20B73EFBFB3DE6857C5DBE23F9BF681D20B73EFBFFEF03B02DB1EF13FE10CF9D51D4BE1BFEF39FAFE422E86400000000000000680EF39FAFE422E86400000000000000680000000000000F07F0000000000000000000000000000F07F182D4454FB2109C0EF39FAFE422E8640182D4454FB2109C0EF39FAFE422E8640182D4454FB2109C0EF39FAFE422EE6BF182D4454FB2109C0000000000000FC9F000000000000FC9FFFFFFFFFFF1F0600000000000000FC9F0000000000200600000000000000FC9F0100000000200600000000000000FC9F000000000000FC1F000000000000FC9F78E0E0F04052ED3F666666666666E69FEF39FAFE422E86400000000000000080EF39FAFE422E86400000000000000080000000000000F07F0000000000000000000000000000F07F182D4454FB2109C0EF39FAFE422E8640182D4454FB2109C0EF39FAFE422E8640182D4454FB2109C0EF39FAFE422EE6BF182D4454FB2109C0000000000000FC9F0100000000000080010000000000008001000000000000800000000000000000010000000000008001000000000000000100000000000080000000000000FC1F010000000000008078E0E0F04052ED3F0000000000000080EF39FAFE422E86400000000000000080EF39FAFE422E86400000000000000080000000000000F07F0000000000000000000000000000F07F182D4454FB210940EF39FAFE422E8640182D4454FB210940EF39FAFE422E8640182D4454FB210940EF39FAFE422EE6BF182D4454FB210940000000000000FC9F0000000000000000010000000000008000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000FC1F000000000000000078E0E0F04052ED3F0000000000000000EF39FAFE422E86400000000000000000EF39FAFE422E86400000000000000000000000000000F07F0000000000000000000000000000F07F182D4454FB210940EF39FAFE422E8640182D4454FB210940EF39FAFE422E8640182D4454FB210940EF39FAFE422EE6BF182D4454FB210940000000000000FC9F0100000000000000010000000000008001000000000000000000000000000000010000000000000001000000000000000100000000000000000000000000FC1F010000000000000078E0E0F04052ED3F0000000000000000EF39FAFE422E86400000000000000000EF39FAFE422E86400000000000000000000000000000F07F0000000000000000000000000000F07F182D4454FB210940EF39FAFE422E8640182D4454FB210940EF39FAFE422E8640182D4454FB210940EF39FAFE422EE6BF182D4454FB210940000000000000FC9F000000000000FC1FFFFFFFFFFF1F0600000000000000FC1F0000000000200600000000000000FC1F0100000000200600000000000000FC1F000000000000FC1F000000000000FC1F78E0E0F04052ED3F666666666666E61FEF39FAFE422E86400000000000000000EF39FAFE422E86400000000000000000000000000000F07F0000000000000000000000000000F07F182D4454FB210940EF39FAFE422E8640182D4454FB210940EF39FAFE422E8640182D4454FB21094078E0E0F04052DD3FD1D40D3DDF47FE3FB3DE6857C5DBE23F9BF681D20B73EF3FB3DE6857C5DBE23F9BF681D20B73EF3FB3DE6857C5DBE23F9BF681D20B73EF3FB3DE6857C5DBE23F9BF681D20B73EF3FB3DE6857C5DBE23F9BF681D20B73EF3FFEF03B02DB1EF13FE10CF9D51D4BE13FEF39FAFE422E86400000000000000600EF39FAFE422E86400000000000000600000000000000F07F0000000000000000000000000000F07F182D4454FB21094036195AC708318640D221337F7CD9024036195AC708318640D221337F7CD90240EF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93F36195AC708318640182D4454FB21E93F36195AC708318640182D4454FB21E93F000000000000F07F0000000000000000000000000000F07F182D4454FB21094036195AC708318640D221337F7CD9024036195AC708318640D221337F7CD90240EF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93FEF39FAFE422E8640182D4454FB21F93F36195AC708318640192D4454FB21E93F36195AC708318640182D4454FB21E93F000000000000F07F0000000000000000000000000000F07FD221337F7CD90240000000000000F07F182D4454FB21F93F000000000000F07F182D4454FB21F93F000000000000F07F182D4454FB21F93F000000000000F07F182D4454FB21F93F000000000000F07F182D4454FB21F93F000000000000F07F182D4454FB21F93F000000000000F07F182D4454FB21F93F000000000000F07F182D4454FB21F93F000000000000F07F182D4454FB21F93F000000000000F07F182D4454FB21F93F000000000000F07F182D4454FB21F93F000000000000F07F182D4454FB21E93FD6B7EDEA607022B93A8C30E28E79453EF56DBB3A189C44B93A8C30E28E79453E1524898ACFC736393A8C30E28E79453E2D4C76038C47F03955AFBC9AF2D77A3E5D98EC06188FEE3955AFBC9AF2D77A3E2C4C76038C47F13955AFBC9AF2D77A3EBF02AAAD5D56C33AA0F0B5A0F7C6B03EC102AAAD5D52C33AA0F0B5A0F7C6B03EBD02AAAD5D5AC33AA0F0B5A0F7C6B03E726403F3A39C973B3FE9E488B5F8E43E746403F39B9C973B3FE9E488B5F8E43E716403F3AB9C973B3FE9E488B5F8E43E45ABE891B2D26C3C91E9D7EBE2361A3F48ABE871B2D26C3C91E9D7EBE2361A3F42ABE8B1B2D26C3C91E9D7EBE2361A3F112A48819997413DD6C8C1004E62503F132A08819997413DD6C8C1004E62503F0F2A88819997413DD6C8C1004E62503F803BBDE18E79153E079A21A6F77A843F81BBBCE18E79153E079A21A6F77A843F7EBBBDE18E79153E079A21A6F77A843F81D5A471CD36EA3E73005C627DA4B93F83D3A471CD36EA3E73005C627DA4B93F7ED7A471CD36EA3E73005C627DA4B93F229A9AC7F78FBC3F44BEEB92E1B6F13F1E9A9AC7F78FBC3F45BEEB92E1B6F13F239A9AC7F78FBC3F44BEEB92E1B6F13F34C2D98D3B4C0F40D36B5F2FAF85074033C2D98D3B4C0F40D36B5F2FAF85074033C2D98D3B4C0F40D36B5F2FAF850740ED7D718CCD0821407B54C5DE04F90840ED7D718CCD0821407B54C5DE04F90840ED7D718CCD0821407B54C5DE04F90840424171066233BABFC0706F9FC766E2BF"> : tensor<203xcomplex> + return %0 : tensor<203xcomplex> + } + func.func public @main() { + %0 = call @samples() : () -> tensor<203xcomplex> + %1 = "chlo.log1p"(%0) : (tensor<203xcomplex>) -> tensor<203xcomplex> + %2 = call @expected() : () -> tensor<203xcomplex> + check.expect_close %1, %2, max_ulp_difference = 3 : tensor<203xcomplex>, tensor<203xcomplex> + func.return + } +} diff --git a/stablehlo/tests/math/log1p_complex64.mlir b/stablehlo/tests/math/log1p_complex64.mlir new file mode 100644 index 0000000000..20c72cbc97 --- /dev/null +++ b/stablehlo/tests/math/log1p_complex64.mlir @@ -0,0 +1,19 @@ +// RUN: stablehlo-opt --chlo-legalize-to-stablehlo %s | stablehlo-translate --interpret +// This file is generated, see build_tools/math/README.md for more information. +module @log1p_complex64 { + func.func private @samples() -> tensor<203xcomplex> { + %0 = stablehlo.constant dense<"0x000080FF000080FFFFFF7FFF000080FFFEFF7FFF000080FF0000C0BF000080FF0000E09F000080FF01000080000080FF00000000000080FF01000000000080FF0000E01F000080FF0000C03F000080FFFEFF7F7F000080FFFFFF7F7F000080FF0000807F000080FF000080FFFFFF7FFFFFFF7FFFFFFF7FFFFEFF7FFFFFFF7FFF0000C0BFFFFF7FFF0000E09FFFFF7FFF01000080FFFF7FFF00000000FFFF7FFF01000000FFFF7FFF0000E01FFFFF7FFF0000C03FFFFF7FFFFEFF7F7FFFFF7FFFFFFF7F7FFFFF7FFF0000807FFFFF7FFF000080FFFEFF7FFFFFFF7FFFFEFF7FFFFEFF7FFFFEFF7FFF0000C0BFFEFF7FFF0000E09FFEFF7FFF01000080FEFF7FFF00000000FEFF7FFF01000000FEFF7FFF0000E01FFEFF7FFF0000C03FFEFF7FFFFEFF7F7FFEFF7FFFFFFF7F7FFEFF7FFF0000807FFEFF7FFF000080FF0000C0BFFFFF7FFF0000C0BFFEFF7FFF0000C0BF0000C0BF0000C0BF0000E09F0000C0BF010000800000C0BF000000000000C0BF010000000000C0BF0000E01F0000C0BF0000C03F0000C0BFFEFF7F7F0000C0BFFFFF7F7F0000C0BF0000807F0000C0BF000080FF0000E09FFFFF7FFF0000E09FFEFF7FFF0000E09F0000C0BF0000E09F0000E09F0000E09F010000800000E09F000000000000E09F010000000000E09F0000E01F0000E09F0000C03F0000E09FFEFF7F7F0000E09FFFFF7F7F0000E09F0000807F0000E09F000080FF01000080FFFF7FFF01000080FEFF7FFF010000800000C0BF010000800000E09F010000800100008001000080000000000100008001000000010000800000E01F010000800000C03F01000080FEFF7F7F01000080FFFF7F7F010000800000807F01000080000080FF00000000FFFF7FFF00000000FEFF7FFF000000000000C0BF000000000000E09F000000000100008000000000000000000000000001000000000000000000E01F000000000000C03F00000000FEFF7F7F00000000FFFF7F7F000000000000807F00000000000080FF01000000FFFF7FFF01000000FEFF7FFF010000000000C0BF010000000000E09F010000000100008001000000000000000100000001000000010000000000E01F010000000000C03F01000000FEFF7F7F01000000FFFF7F7F010000000000807F01000000000080FF0000E01FFFFF7FFF0000E01FFEFF7FFF0000E01F0000C0BF0000E01F0000E09F0000E01F010000800000E01F000000000000E01F010000000000E01F0000E01F0000E01F0000C03F0000E01FFEFF7F7F0000E01FFFFF7F7F0000E01F0000807F0000E01F000080FF0000C03FFFFF7FFF0000C03FFEFF7FFF0000C03F0000C0BF0000C03F0000E09F0000C03F010000800000C03F000000000000C03F010000000000C03F0000E01F0000C03F0000C03F0000C03FFEFF7F7F0000C03FFFFF7F7F0000C03F0000807F0000C03F000080FFFEFF7F7FFFFF7FFFFEFF7F7FFEFF7FFFFEFF7F7F0000C0BFFEFF7F7F0000E09FFEFF7F7F01000080FEFF7F7F00000000FEFF7F7F01000000FEFF7F7F0000E01FFEFF7F7F0000C03FFEFF7F7FFEFF7F7FFEFF7F7FFFFF7F7FFEFF7F7F0000807FFEFF7F7F000080FFFFFF7F7FFFFF7FFFFFFF7F7FFEFF7FFFFFFF7F7F0000C0BFFFFF7F7F0000E09FFFFF7F7F01000080FFFF7F7F00000000FFFF7F7F01000000FFFF7F7F0000E01FFFFF7F7F0000C03FFFFF7F7FFEFF7F7FFFFF7F7FFFFF7F7FFFFF7F7F0000807FFFFF7F7F000080FF0000807FFFFF7FFF0000807FFEFF7FFF0000807F0000C0BF0000807F0000E09F0000807F010000800000807F000000000000807F010000000000807F0000E01F0000807F0000C03F0000807FFEFF7F7F0000807FFFFF7F7F0000807F0000807F0000807F959566A477CC2B32969566A477CC2B32949566A477CC2B32DC24B4A795BFD633DD24B4A795BFD633DB24B4A795BFD633CCBC0CABBD378635CDBC0CABBD378635CBBC0CABBD378635FEE65BAEACC52737FFE65BAEACC52737FDE65BAEACC5273776CCABB117B7D13877CCABB117B7D13875CCABB117B7D138BE3706B56F12833ABF3706B56F12833ABD3706B56F12833A17B751B80AD7233C18B751B80AD7233C16B751B80AD7233C0BD7A3BBCDCCCC3D0CD7A3BBCDCCCC3D0AD7A3BBCDCCCC3D000000BF0000803F010000BF0000803FFFFFFFBE0000803F000048C200002041FFFF47C200002041FFFF47C20000204100409CC50000C842FF3F9CC50000C842FF3F9CC50000C842064A78BE9D5FFBBE"> : tensor<203xcomplex> + return %0 : tensor<203xcomplex> + } + func.func private @expected() -> tensor<203xcomplex> { + %0 = stablehlo.constant dense<"0x0000807FE4CB16C00000807FDB0FC9BF0000807FDB0FC9BF0000807FDB0FC9BF0000807FDB0FC9BF0000807FDB0FC9BF0000807FDB0FC9BF0000807FDB0FC9BF0000807FDB0FC9BF0000807FDB0FC9BF0000807FDB0FC9BF0000807FDB0FC9BF0000807FDB0F49BF0000807FDB0F49C08A23B242E4CB16C08A23B242E4CB16C01872B142DB0FC9BF1872B142DB0FC9BF1872B142DB0FC9BF1872B142DB0FC9BF1872B142DB0FC9BF1872B142DB0FC9BF1872B142DB0FC9BF8A23B242DB0F49BF8A23B242DB0F49BF0000807F000000000000807FDB0F49C08A23B242E4CB16C08A23B242E4CB16C01872B142DB0FC9BF1872B142DB0FC9BF1872B142DB0FC9BF1872B142DB0FC9BF1872B142DB0FC9BF1872B142DB0FC9BF1872B142DB0FC9BF8A23B242DB0F49BF8A23B242DA0F49BF0000807F000000000000807FDB0F49C01872B142DB0F49C01872B142DB0F49C00892EA3EFA3EF2BF2BDE163F5F987BBF2BDE163F5F987BBF2BDE163F5F987BBF2BDE163F5F987BBF2BDE163F5F987BBFD8F6883FEF580ABF1872B142000030801872B142000030800000807F000000000000807FDB0F49C01872B142DB0F49C01872B142DB0F49C0187231BFDB0F49C00000E09F0000E09FFFFF30000000E09F000031000000E09F010031000000E09F0000E01F0000E09F08926A3F3333339F1872B142000000801872B142000000800000807F000000000000807FDB0F49C01872B142DB0F49C01872B142DB0F49C0187231BFDB0F49C00000E09F010000800100008001000080000000000100008001000000010000800000E01F0100008008926A3F000000801872B142000000801872B142000000800000807F000000000000807FDB0F49401872B142DB0F49401872B142DB0F4940187231BFDB0F49400000E09F000000000100008000000000000000000000000001000000000000000000E01F0000000008926A3F000000001872B142000000001872B142000000000000807F000000000000807FDB0F49401872B142DB0F49401872B142DB0F4940187231BFDB0F49400000E09F010000000100008001000000000000000100000001000000010000000000E01F0100000008926A3F000000001872B142000000001872B142000000000000807F000000000000807FDB0F49401872B142DB0F49401872B142DB0F4940187231BFDB0F49400000E09F0000E01FFFFF30000000E01F000031000000E01F010031000000E01F0000E01F0000E01F08926A3F3333331F1872B142000000001872B142000000000000807F000000000000807FDB0F49401872B142DB0F49401872B142DB0F49400892EA3EFA3EF23F2BDE163F5F987B3F2BDE163F5F987B3F2BDE163F5F987B3F2BDE163F5F987B3F2BDE163F5F987B3FD8F6883FEF580A3F1872B142000030001872B142000030000000807F000000000000807FDB0F49408A23B242E4CB16408A23B242E4CB16401872B142DB0FC93F1872B142DB0FC93F1872B142DB0FC93F1872B142DB0FC93F1872B142DB0FC93F1872B142DB0FC93F1872B142DB0FC93F8A23B242DB0F493F8A23B242DA0F493F0000807F000000000000807FDB0F49408A23B242E4CB16408A23B242E4CB16401872B142DB0FC93F1872B142DB0FC93F1872B142DB0FC93F1872B142DB0FC93F1872B142DB0FC93F1872B142DB0FC93F1872B142DB0FC93F8A23B242DB0F493F8A23B242DB0F493F0000807F000000000000807FE4CB16400000807FDB0FC93F0000807FDB0FC93F0000807FDB0FC93F0000807FDB0FC93F0000807FDB0FC93F0000807FDB0FC93F0000807FDB0FC93F0000807FDB0FC93F0000807FDB0FC93F0000807FDB0FC93F0000807FDB0FC93F0000807FDB0F493FBC82E09777CC2B32AF20B89877CC2B32A2BE0F1877CC2B327359771B95BFD6334753849B95BFD6335DD63D1C95BFD633D4311F9CBD378635643E819FBD37863539837D1FBD378635E575A320ACC5273743916BA2ACC527375E378A22ACC52737BE18872517B7D13885CE71A517B7D1385F8C432617B7D138DFA2032A7012833AC14587297012833ADCA2432A7012833A43AAAB30BDD7233C452AAB30BDD7233C412AAC30BDD7233C8CB55137EB23CD3D8FB35137EB23CD3D8AB75137EB23CD3DBE7FE43D0DB78D3FBB7FE43D0DB78D3FC07FE43D0CB78D3FDC617A40792D3C40DC617A40792D3C40DC617A40792D3C406C46084127C847406C46084127C847406C46084127C84740109BD1BD3D3613BF"> : tensor<203xcomplex> + return %0 : tensor<203xcomplex> + } + func.func public @main() { + %0 = call @samples() : () -> tensor<203xcomplex> + %1 = "chlo.log1p"(%0) : (tensor<203xcomplex>) -> tensor<203xcomplex> + %2 = call @expected() : () -> tensor<203xcomplex> + check.expect_close %1, %2, max_ulp_difference = 3 : tensor<203xcomplex>, tensor<203xcomplex> + func.return + } +} diff --git a/stablehlo/tests/math/log1p_float32.mlir b/stablehlo/tests/math/log1p_float32.mlir new file mode 100644 index 0000000000..50a4e025b1 --- /dev/null +++ b/stablehlo/tests/math/log1p_float32.mlir @@ -0,0 +1,19 @@ +// RUN: stablehlo-opt --chlo-legalize-to-stablehlo %s | stablehlo-translate --interpret +// This file is generated, see build_tools/math/README.md for more information. +module @log1p_float32 { + func.func private @samples() -> tensor<175xf32> { + %0 = stablehlo.constant dense<"0x000080FFFFFF7FFFFEFF7FFF05E763FC88DAD5FA0BCE47F98EC1B9F711B52BF695A89DF4189C0FF39B8F81F11E83F3EFA17665EE246AD7ECA75D49EB2B51BBE9AE442DE831389FE6B42B11E5371F83E3BA12F5E13D0667E0C1F9D8DE44ED4ADDC7E0BCDB4AD42EDACDC7A0D850BB12D7D3AE84D557A2F6D3DA9568D25D89DAD0E07C4CCF6370BECDE66330CC6957A2CAED4A14C9703E86C7F331F8C576256AC4F918DCC27C0C4EC10000C0BF83F331BE06E7A3BC89DA15BB0CCE87B98FC1F9B712B56BB696A8DDB4199C4FB39C8FC1B11F8333B0A276A5AE256A17ADA85D89AB2C51FBA9AF446DA83238DFA6B52B51A5381FC3A3BB1235A23E06A7A0C2F9189F45ED8A9DC8E0FC9B4BD46E9ACEC7E09851BB5297D4AEC49558A23694DB95A8925E891A91E17C8C8F6470FE8DE763708C6A57E28AEE4A5489713EC687F43138867725AA84FA181C837D0C8E810100008000000000010000007D0C8E01FA181C037725AA04F4313806713EC607EE4A54096A57E20AE763700C6470FE0DE17C8C0F5E891A11DB95A81258A23614D4AEC41551BB5217CEC7E0184BD46E1AC8E0FC1B45ED8A1DC2F9181F3E06A720BB123522381FC323B52B51253238DF26AF446D282C51FB29A85D892B256A172DA276A52E1F8333309C8FC131199C4F3396A8DD3412B56B368FC1F9370CCE873989DA153B06E7A33C83F3313E0000C03F7C0C4E41F918DC4276256A44F331F845703E8647ED4A14496957A24AE663304C6370BE4DE07C4C4F5D89DA50DA95685257A2F653D3AE845550BB1257CDC7A0584AD42E5AC7E0BC5B44ED4A5DC1F9D85E3D066760BA12F561371F8363B42B116531389F66AE442D682B51BB69A75D496B246AD76CA176656E1E83F36F9B8F8171189C0F7395A89D7411B52B768EC1B9770BCE477988DAD57A05E7637CFEFF7F7FFFFF7F7F0000807F010080BF000080BFFFFF7FBFFFFF7F3F0000803F0100803F"> : tensor<175xf32> + return %0 : tensor<175xf32> + } + func.func private @expected() -> tensor<175xf32> { + %0 = stablehlo.constant dense<"0x0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07F0000C07FEC7943BE7590A5BC760616BB8DD287B983C2F9B72DB56BB699A8DDB4199C4FB39C8FC1B11F8333B0A276A5AE256A17ADA85D89AB2C51FBA9AF446DA83238DFA6B52B51A5381FC3A3BB1235A23E06A7A0C2F9189F45ED8A9DC8E0FC9B4BD46E9ACEC7E09851BB5297D4AEC49558A23694DB95A8925E891A91E17C8C8F6470FE8DE763708C6A57E28AEE4A5489713EC687F43138867725AA84FA181C837D0C8E810100008000000000010000007D0C8E01FA181C037725AA04F4313806713EC607EE4A54096A57E20AE763700C6470FE0DE17C8C0F5E891A11DB95A81258A23614D4AEC41551BB5217CEC7E0184BD46E1AC8E0FC1B45ED8A1DC2F9181F3E06A720BB123522381FC323B52B51253238DF26AF446D282C51FB29A85D892B256A172DA276A52E1F8333309C8FC131199C4F3393A8DD34F7B46B369BC0F9378CC98739BEAE153BCA48A23C4313243E08926A3FF956284012B8964061FCDA4065AE0F413D3532414012554162CA7741DD318D4182719E41F9A5AF41BFD0C0410BF3D141DA0DE3417846F441A4DB02429E8A0B42BF3114423ED21C420E6D2542F3022E428B94364257223F4208B947429B7250428B2259427ACA6142A96B6A4210077342799D7B42C2178242DB5E864257A78A42BA048F422F5D934290B1974281029C428150A042F89BA44238E5A8421872B1421872B1420000807F0000C07F000080FF921585C11772313F1872313F1972313F"> : tensor<175xf32> + return %0 : tensor<175xf32> + } + func.func public @main() { + %0 = call @samples() : () -> tensor<175xf32> + %1 = "chlo.log1p"(%0) : (tensor<175xf32>) -> tensor<175xf32> + %2 = call @expected() : () -> tensor<175xf32> + check.expect_close %1, %2, max_ulp_difference = 3 : tensor<175xf32>, tensor<175xf32> + func.return + } +} diff --git a/stablehlo/tests/math/log1p_float64.mlir b/stablehlo/tests/math/log1p_float64.mlir new file mode 100644 index 0000000000..3eab9fb7e5 --- /dev/null +++ b/stablehlo/tests/math/log1p_float64.mlir @@ -0,0 +1,19 @@ +// RUN: stablehlo-opt --chlo-legalize-to-stablehlo %s | stablehlo-translate --interpret +// This file is generated, see build_tools/math/README.md for more information. +module @log1p_float64 { + func.func private @samples() -> tensor<175xf64> { + %0 = stablehlo.constant dense<"0x000000000000F0FFFFFFFFFFFFFFEFFFFEFFFFFFFFFFEFFF2A51BB12B52BD1FCC0F9189C8FC141FB56A276256A57B2F9EC4AD4AE44ED22F882F331381F8393F6189C8FC1F91804F5AE44ED4AD4AE74F343ED4AD4AE44E5F1D995A85D89DA55F06F3E06E76370C6EE05E763703E0637ED9B8FC1F9189CA7EB31381F83F33118EAC7E07C0CCEC788E85D89DA95A85DF9E6F231381F83F369E588DA95A85D89DAE31E83F331381F4BE2B42B51BB12B5BBE04AD4AE44ED4A2CDFE07C0CCEC7E09CDD76256A57A2760DDC0CCEC7E07C0C7EDAA176256A57A2EED8371F83F331385FD7CDC7E07C0CCECFD563703E06E76340D4F9189C8FC1F9B0D28FC1F9189C8F21D1256A57A2762592CFBB12B52B51BB02CE50BB12B52B5173CCE663703E06E7E3CA7C0CCEC7E07C54C912B52B51BB12C5C7A85D89DA95A835C63E06E763703EA6C4D4AE44ED4AD416C36A57A276256A87C1000000000000F8BF95A85D89DA9568BE2B51BB12B52BD9BCC1F9189C8FC149BB57A276256A57BAB9ED4AD4AE44ED2AB883F331381F839BB6199C8FC1F9180CB5AF44ED4AD4AE7CB344ED4AD4AE44EDB1DA95A85D89DA5DB0703E06E76370CEAE06E763703E063FAD9C8FC1F9189CAFAB32381F83F33120AAC8E07C0CCEC790A85E89DA95A85D01A7F331381F83F371A589DA95A85D89E2A31F83F331381F53A2B52B51BB12B5C3A04BD4AE44ED4A349FE17C0CCEC7E0A49D77256A57A276159C0DCEC7E07C0C869AA276256A57A2F698381F83F331386797CEC7E07C0CCED79564703E06E7634894FA189C8FC1F9B89290C1F9189C8F2991266A57A276259A8FBC12B52B51BB0A8E51BB12B52B517B8CE763703E06E7EB8A7D0CCEC7E07C5C8913B52B51BB12CD87A95D89DA95A83D863F06E763703EAE84D5AE44ED4AD41E836B57A276256A8F810100000000000080000000000000000001000000000000006B57A276256A8F01D5AE44ED4AD41E033F06E763703EAE04A95D89DA95A83D0613B52B51BB12CD077D0CCEC7E07C5C09E763703E06E7EB0A51BB12B52B517B0CBC12B52B51BB0A0E266A57A276259A0F90C1F9189C8F2911FA189C8FC1F9B81264703E06E7634814CEC7E07C0CCED715381F83F331386717A276256A57A2F6180DCEC7E07C0C861A77256A57A276151CE17C0CCEC7E0A41D4BD4AE44ED4A341FB52B51BB12B5C3201F83F331381F532289DA95A85D89E223F331381F83F371255E89DA95A85D0127C8E07C0CCEC7902832381F83F331202A9C8FC1F9189CAF2B06E763703E063F2D703E06E76370CE2EDA95A85D89DA5D3044ED4AD4AE44ED31AF44ED4AD4AE7C33199C8FC1F9180C3583F331381F839B36ED4AD4AE44ED2A3857A276256A57BA39C1F9189C8FC1493B2B51BB12B52BD93C95A85D89DA95683E000000000000F83F6A57A276256A8741D4AE44ED4AD416433E06E763703EA644A85D89DA95A8354612B52B51BB12C5477C0CCEC7E07C5449E663703E06E7E34A50BB12B52B51734CBB12B52B51BB024E256A57A27625924F8FC1F9189C8F2151F9189C8FC1F9B05263703E06E7634054CDC7E07C0CCECF55371F83F331385F57A176256A57A2EE580CCEC7E07C0C7E5A76256A57A2760D5CE07C0CCEC7E09C5D4AD4AE44ED4A2C5FB42B51BB12B5BB601E83F331381F4B6288DA95A85D89DA63F231381F83F369655D89DA95A85DF966C7E07C0CCEC7886831381F83F331186A9B8FC1F9189CA76B05E763703E06376D6F3E06E76370C66ED995A85D89DA557043ED4AD4AE44E571AE44ED4AD4AE7473189C8FC1F918047582F331381F839376EC4AD4AE44ED227856A276256A57B279C0F9189C8FC1417B2A51BB12B52BD17CFEFFFFFFFFFFEF7FFFFFFFFFFFFFEF7F000000000000F07F010000000000F0BF000000000000F0BFFFFFFFFFFFFFEFBFFFFFFFFFFFFFEF3F000000000000F03F010000000000F03F"> : tensor<175xf64> + return %0 : tensor<175xf64> + } + func.func private @expected() -> tensor<175xf64> { + %0 = stablehlo.constant dense<"0x000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F000000000000F87F616BCF92DA9568BE3051BB12B52BD9BCC1F9189C8FC149BB57A276256A57BAB9ED4AD4AE44ED2AB883F331381F839BB6199C8FC1F9180CB5AF44ED4AD4AE7CB344ED4AD4AE44EDB1DA95A85D89DA5DB0703E06E76370CEAE06E763703E063FAD9C8FC1F9189CAFAB32381F83F33120AAC8E07C0CCEC790A85E89DA95A85D01A7F331381F83F371A589DA95A85D89E2A31F83F331381F53A2B52B51BB12B5C3A04BD4AE44ED4A349FE17C0CCEC7E0A49D77256A57A276159C0DCEC7E07C0C869AA276256A57A2F698381F83F331386797CEC7E07C0CCED79564703E06E7634894FA189C8FC1F9B89290C1F9189C8F2991266A57A276259A8FBC12B52B51BB0A8E51BB12B52B517B8CE763703E06E7EB8A7D0CCEC7E07C5C8913B52B51BB12CD87A95D89DA95A83D863F06E763703EAE84D5AE44ED4AD41E836B57A276256A8F810100000000000080000000000000000001000000000000006B57A276256A8F01D5AE44ED4AD41E033F06E763703EAE04A95D89DA95A83D0613B52B51BB12CD077D0CCEC7E07C5C09E763703E06E7EB0A51BB12B52B517B0CBC12B52B51BB0A0E266A57A276259A0F90C1F9189C8F2911FA189C8FC1F9B81264703E06E7634814CEC7E07C0CCED715381F83F331386717A276256A57A2F6180DCEC7E07C0C861A77256A57A276151CE17C0CCEC7E0A41D4BD4AE44ED4A341FB52B51BB12B5C3201F83F331381F532289DA95A85D89E223F331381F83F371255E89DA95A85D0127C8E07C0CCEC7902832381F83F331202A9C8FC1F9189CAF2B06E763703E063F2D703E06E76370CE2EDA95A85D89DA5D3044ED4AD4AE44ED31AF44ED4AD4AE7C33199C8FC1F9180C3583F331381F839B36ED4AD4AE44ED2A3857A276256A57BA39C1F9189C8FC1493B2651BB12B52BD93CD2E5EB7FDA95683E78E0E0F04052ED3FD36BF2A59EB531408C923CE1A38141406B04AAE262284A40B79D659885675140CAF791C6CDBA5540B805264F090E5A40DB2D687637615E4041F9E6B72B5A614028F5F42DB48363405CC602A334AD6540B120AB90ACD66740F898DC621B006A40D029EE7580296C40BCBAF17D0D536E40FA8CABED7C3E7040D2CDA9AB715371406A4BB9EA646872405AB5C89B567D7340F67CDEAE469274408BCE051335A775404D8D39B621BC7640D6104D850CD17740D358D26BF5E578401260FD53DCFA7940E9298426C10F7B40B3147BCAA3247C405FE82C2584397D408000EE19624E7E403AD5E9893D637F402002F5290B3C8040F7E80A2A76C680402474D4B1DF5081402FEE4FAC47DB8140765BAC02AE658240E2AF129C12F08240BAAB665D757A83408BCCFD28D6048440B0634ADE348F8440C36F785991198540EF39FAFE422E8640EF39FAFE422E8640000000000000F07F000000000000F87F000000000000F0FFFA37277B4F5E42C0EF39FAFE422EE63FEF39FAFE422EE63FF039FAFE422EE63F"> : tensor<175xf64> + return %0 : tensor<175xf64> + } + func.func public @main() { + %0 = call @samples() : () -> tensor<175xf64> + %1 = "chlo.log1p"(%0) : (tensor<175xf64>) -> tensor<175xf64> + %2 = call @expected() : () -> tensor<175xf64> + check.expect_close %1, %2, max_ulp_difference = 3 : tensor<175xf64>, tensor<175xf64> + func.return + } +} diff --git a/stablehlo/transforms/ChloDecompositionPatterns.td b/stablehlo/transforms/ChloDecompositionPatterns.td index 66170fb547..2a68061efc 100644 --- a/stablehlo/transforms/ChloDecompositionPatterns.td +++ b/stablehlo/transforms/ChloDecompositionPatterns.td @@ -117,5 +117,9 @@ def : Pat<(CHLO_ConstantOp $v), (StableHLO_ConstantOp $v)>; +def : Pat<(CHLO_Log1pOp NonComplexElementType:$x), + (StableHLO_Log1pOp $x)>; + + // Include generated implementations of math functions: include "ChloDecompositionPatternsMath.td" diff --git a/stablehlo/transforms/ChloDecompositionPatternsMath.td b/stablehlo/transforms/ChloDecompositionPatternsMath.td index 3d1be0d4f6..0b791ab658 100644 --- a/stablehlo/transforms/ChloDecompositionPatternsMath.td +++ b/stablehlo/transforms/ChloDecompositionPatternsMath.td @@ -14,7 +14,7 @@ limitations under the License. ==============================================================================*/ // -// This file is generated using functional_algorithms tool (0.11.1). +// This file is generated using functional_algorithms tool (0.12.0). // See build_tools/math/README.md for more information. // A kernel for evaluating asin and acos functions on complex inputs. @@ -913,3 +913,243 @@ def : Pat<(CHLO_SquareOp ComplexElementType:$z), // Square on real input: x * x def : Pat<(CHLO_SquareOp NonComplexElementType:$x), (StableHLO_MulOp $x, $x)>; + +// Logarithm of 1 + z on complex input: +// +// log1p(x + I * y) = 0.5 * log((x + 1) ** 2 + y ** 2) + I * arctan2(y, x + 1) +// +// where +// +// x and y are real and imaginary parts of the input to log1p, and +// I is imaginary unit. +// +// For evaluating the real part of log1p accurately on the whole +// complex plane, the following cases must be handled separately: +// +// A) Avoid catastrophic cancellation errors when x is close `-0.5 * y * y` +// and `abs(y) < 1`. +// B) Avoid overflow from square when x or y are large in absolute value. +// C) Avoid cancellation errors when x is close to -1 and y is not large. +// D) Avoid cancellation errors when x is close to -2 and y is not large. +// +// Case A +// ------ +// +// The real part of log1p reads: +// +// 0.5 * log((x + 1) ** 2 + y ** 2) = 0.5 * log1p(x + x + x * x + y * y) +// +// When abs(y) < 1 and abs(x + 0.5 * y ** 2) is small, catastrophic +// cancellation errors occur when evaluating `x + x + x * x + y * y` +// using floating-point arithmetics. To avoid these errors, we'll use +// Dekker's product for computing `x * x` and `y * y` which +// effectively doubles the precision of the used floating-point +// system. In addition, the terms are summed together using 2Sum +// algorithm that minimizes cancellation errors. We'll have +// +// xxh, xxl = square_dekker(x) +// yyh, yyl = square_dekker(y) +// x + x + x * x + y * y = sum_2sum([x + x, yyh, xxh, yyl, xxl]) +// +// which is accurate when the following inequalities hold: +// +// abs(x) < sqrt(largest) * 0.1 +// abs(y) < sqrt(largest) * 0.99 +// +// [verified numerically for float32 and float64], except when x is +// close to -1 (see Case C). +// +// Case B +// ------ +// +// If abs(x) or abs(y) is larger than sqrt(largest), squareing +// these will overflow. To avoid such overflows, we'll apply +// rescaling of log1p arguments. +// +// First notice that if `abs(x) > sqrt(largest) > 4 / eps` holds then +// `x + 1 ~= x`. Also, if `abs(x) < 4 / eps` then `(x + 1) ** 2 + y +// ** 2 ~= y ** 2`. Proof: +// +// (x + 1) ** 2 + y ** 2 ~= y ** 2 iff y ** 2 > 4 * (x + 1) ** 2 / eps +// +// The lower limit to `y ** 2` is largest. The upper limit to +// `4 * (x + 1) ** 2 / eps` is `64 / eps ** 3` which is smaller than +// largest. QED. +// +// In conclusion, we can write +// +// (x + 1) ** 2 + y ** 2 ~= x ** 2 + y ** 2 +// +// whenever abs(x) or abs(y) is greater than sqrt(largest). +// +// Define +// +// mx = max(abs(x), abs(y)) +// mn = min(abs(x), abs(y)) +// +// then under the given restrictions we'll have +// +// real(log(x + I * y)) ~= 0.5 * log(x ** 2 + y ** 2) +// = 0.5 * log(mx ** 2 * (1 + (mn / mx) ** 2)) +// = log(mx) + 0.5 * log1p((mn / mx) ** 2) +// +// If mn == inf and mx == inf, we'll define `mn / mx == 1` for the +// sake of reusing the above expression for complex infinities +// (recall, `real(log(+-inf +-inf * I)) == inf`). +// +// Case C +// ------ +// +// If x is close to -1, then we'll use +// +// real(log1p(x + I * y)) = 0.5 * log((1 + x) ** 2 + y ** 2) +// +// which is accurate when the following inequalities hold: +// +// -1.5 < x < -0.5 or abs(x + 1) < 0.5 +// abs(y) < sqrt(largest) +// +// [verified numerically for float32 and float64]. For simplicity, +// we'll use the case C only when `abs(x) + abs(y) < 0.2`. +// +// Case D +// ------ +// +// If x is close to -2, the cancellation errors are avoided by using +// the Case A method [verified numerically for float32 and float64]. +// +// +def : Pat<(CHLO_Log1pOp ComplexElementType:$z), + (StableHLO_ComplexOp + (StableHLO_SelectOp + (StableHLO_CompareOp + (StableHLO_MaxOp:$mx + (StableHLO_AbsOp:$ax + (StableHLO_RealOp:$x $z)), + (StableHLO_AbsOp:$ay + (StableHLO_ImagOp:$y $z))), + (StableHLO_MulOp + (StableHLO_SqrtOp + (StableHLO_ConstantLikeMaxFiniteValue:$largest $x)), + (StableHLO_ConstantLike<"0.01"> $x)), + StableHLO_ComparisonDirectionValue<"GT">, + (STABLEHLO_DEFAULT_COMPARISON_TYPE)), + (StableHLO_AddOp + (StableHLO_LogOp $mx), + (StableHLO_MulOp + (StableHLO_ConstantLike<"0.5">:$half $x), + (StableHLO_Log1pOp + (StableHLO_SelectOp + (StableHLO_CompareOp + (StableHLO_MinOp:$mn $ax, $ay), + $mx, + StableHLO_ComparisonDirectionValue<"EQ">, + (STABLEHLO_DEFAULT_COMPARISON_TYPE)), + (StableHLO_ConstantLike<"1">:$one $x), + (StableHLO_MulOp + (StableHLO_DivOp:$r $mn, $mx), + $r))))), + (StableHLO_SelectOp + (StableHLO_CompareOp + (StableHLO_AddOp + (StableHLO_AbsOp + (StableHLO_AddOp:$xp1 $x, $one)), + $ay), + (StableHLO_ConstantLike<"0.2"> $x), + StableHLO_ComparisonDirectionValue<"LT">, + (STABLEHLO_DEFAULT_COMPARISON_TYPE)), + (StableHLO_MulOp + $half, + (StableHLO_LogOp + (StableHLO_AddOp + (StableHLO_MulOp $xp1, $xp1), + (StableHLO_MulOp:$square_dekker_high $y, $y)))), + (StableHLO_MulOp + $half, + (StableHLO_Log1pOp + (StableHLO_AddOp:$sum_2sum_high + (StableHLO_AddOp:$add_2sum_high + (StableHLO_AddOp:$_add_2sum_high_0_ + (StableHLO_AddOp:$_add_2sum_high_1_ + (StableHLO_AddOp:$_add_2sum_high_2_ + (StableHLO_AddOp:$x2h $x, $x), + $square_dekker_high), + (StableHLO_MulOp:$_square_dekker_high_0_ $x, $x)), + (StableHLO_AddOp:$square_dekker_low + (StableHLO_AddOp + (StableHLO_AddOp + (StableHLO_AddOp + (StableHLO_NegOp $square_dekker_high), + (StableHLO_MulOp + (StableHLO_AddOp:$yh + (StableHLO_MulOp:$multiply_veltkamp_splitter_constant_y + (StableHLO_SelectOp:$veltkamp_splitter_constant + (StableHLO_CompareOp + $largest, + (StableHLO_ConstantLike<"1e+308"> $x), + StableHLO_ComparisonDirectionValue<"GT">, + (STABLEHLO_DEFAULT_COMPARISON_TYPE)), + (StableHLO_ConstantLike<"134217729"> $x), + (StableHLO_SelectOp + (StableHLO_CompareOp + $largest, + (StableHLO_ConstantLike<"1e+38"> $x), + StableHLO_ComparisonDirectionValue<"GT">, + (STABLEHLO_DEFAULT_COMPARISON_TYPE)), + (StableHLO_ConstantLike<"4097"> $x), + (StableHLO_ConstantLike<"65"> $x))), + $y), + (StableHLO_SubtractOp $y, $multiply_veltkamp_splitter_constant_y)), + $yh)), + (StableHLO_MulOp:$multiply_yh_yl + $yh, + (StableHLO_SubtractOp:$yl $y, $yh))), + $multiply_yh_yl), + (StableHLO_MulOp $yl, $yl))), + (StableHLO_AddOp:$_square_dekker_low_0_ + (StableHLO_AddOp + (StableHLO_AddOp + (StableHLO_AddOp + (StableHLO_NegOp $_square_dekker_high_0_), + (StableHLO_MulOp + (StableHLO_AddOp:$xh + (StableHLO_MulOp:$multiply_veltkamp_splitter_constant_x $veltkamp_splitter_constant, $x), + (StableHLO_SubtractOp $x, $multiply_veltkamp_splitter_constant_x)), + $xh)), + (StableHLO_MulOp:$multiply_xh_xl + $xh, + (StableHLO_SubtractOp:$xl $x, $xh))), + $multiply_xh_xl), + (StableHLO_MulOp $xl, $xl))), + (StableHLO_AddOp + (StableHLO_AddOp + (StableHLO_AddOp + (StableHLO_AddOp:$add_2sum_low + (StableHLO_SubtractOp + $x2h, + (StableHLO_SubtractOp + $_add_2sum_high_2_, + (StableHLO_SubtractOp:$subtract__add_2sum_high_2__x2h $_add_2sum_high_2_, $x2h))), + (StableHLO_SubtractOp $square_dekker_high, $subtract__add_2sum_high_2__x2h)), + (StableHLO_AddOp:$_add_2sum_low_0_ + (StableHLO_SubtractOp + $_add_2sum_high_2_, + (StableHLO_SubtractOp + $_add_2sum_high_1_, + (StableHLO_SubtractOp:$subtract__add_2sum_high_1___add_2sum_high_2_ $_add_2sum_high_1_, $_add_2sum_high_2_))), + (StableHLO_SubtractOp $_square_dekker_high_0_, $subtract__add_2sum_high_1___add_2sum_high_2_))), + (StableHLO_AddOp:$_add_2sum_low_1_ + (StableHLO_SubtractOp + $_add_2sum_high_1_, + (StableHLO_SubtractOp + $_add_2sum_high_0_, + (StableHLO_SubtractOp:$subtract__add_2sum_high_0___add_2sum_high_1_ $_add_2sum_high_0_, $_add_2sum_high_1_))), + (StableHLO_SubtractOp $square_dekker_low, $subtract__add_2sum_high_0___add_2sum_high_1_))), + (StableHLO_AddOp:$_add_2sum_low_2_ + (StableHLO_SubtractOp + $_add_2sum_high_0_, + (StableHLO_SubtractOp + $add_2sum_high, + (StableHLO_SubtractOp:$subtract_add_2sum_high__add_2sum_high_0_ $add_2sum_high, $_add_2sum_high_0_))), + (StableHLO_SubtractOp $_square_dekker_low_0_, $subtract_add_2sum_high__add_2sum_high_0_)))))))), + (StableHLO_Atan2Op $y, $xp1))>;