.. _op_ai_onnx_Log1p: Log1p ===== - **Domain**: ``ai.onnx`` - **Since version**: 29 Computes ``y = ln(1 + x)`` element-wise, where ``ln`` is the natural logarithm. The output has the same shape and element type as the input, including for scalar and empty inputs. For finite ``x > -1``, the result is a floating-point approximation of ``ln(1 + x)``, with ``1 + x`` evaluated as an exact real sum. Small nonzero results representable in the output type must be preserved even when floating-point addition would round ``1 + x`` to ``1``. For example, a FLOAT input of ``1e-8`` produces approximately ``1e-8``. Special values are defined element-wise as follows: | Input ``x`` | Output ``y`` | | --- | --- | | Positive zero | Positive zero | | Negative zero | Negative zero | | ``-1`` | Negative infinity | | Finite ``x < -1`` | NaN | | Negative infinity | NaN | | Positive infinity | Positive infinity | | NaN | NaN | The sign and payload of an output NaN are unspecified. **Inputs** - **input** (*T*): Input tensor **Outputs** - **output** (*T*): The natural logarithm of one plus the input, computed element-wise **Type Constraints** - **T**: Constrain input and output types to float tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16). Examples -------- **test_cc_supported_dtype_Log1p_BFLOAT16** .. code-block:: text Node: Log1p(X) -> (Y) .. code-block:: text Inputs: X: shape=(7,), dtype=bfloat16 [-0.75, -0.5, -5.96046e-08, 0, 5.96046e-08, 0.5, 2] Outputs: Y: shape=(7,), dtype=bfloat16 [-1.38281, -0.691406, -5.96046e-08, 0, 5.96046e-08, 0.40625, 1.10156] **test_cc_supported_dtype_Log1p_DOUBLE** .. code-block:: text Node: Log1p(X) -> (Y) .. code-block:: text Inputs: X: shape=(7,), dtype=float64 [-7.50000000e-01, -5.00000000e-01, -5.96046448e-08, 0.00000000e+00, 5.96046448e-08, 5.00000000e-01, 2.00000000e+00] Outputs: Y: shape=(7,), dtype=float64 [-1.38629436e+00, -6.93147181e-01, -5.96046466e-08, 0.00000000e+00, 5.96046430e-08, 4.05465108e-01, 1.09861229e+00] **test_cc_supported_dtype_Log1p_FLOAT16** .. code-block:: text Node: Log1p(X) -> (Y) .. code-block:: text Inputs: X: shape=(7,), dtype=float16 [-7.5e-01, -5.0e-01, -6.0e-08, 0.0e+00, 6.0e-08, 5.0e-01, 2.0e+00] Outputs: Y: shape=(7,), dtype=float16 [-1.387e+00, -6.934e-01, -5.960e-08, 0.000e+00, 5.960e-08, 4.055e-01, 1.099e+00] **test_cc_supported_dtype_Log1p_empty_bfloat16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(0, 3), dtype=bfloat16 [] Outputs: y: shape=(0, 3), dtype=bfloat16 [] **test_cc_supported_dtype_Log1p_empty_float16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(0, 3), dtype=float16 [] Outputs: y: shape=(0, 3), dtype=float16 [] **test_cc_supported_dtype_Log1p_empty_float32** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(0, 3), dtype=float32 [] Outputs: y: shape=(0, 3), dtype=float32 [] **test_cc_supported_dtype_Log1p_empty_float64** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(0, 3), dtype=float64 [] Outputs: y: shape=(0, 3), dtype=float64 [] **test_cc_supported_dtype_Log1p_finite_bfloat16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(2, 4), dtype=bfloat16 [[-0.875, -0.5, 0, 0.25], [0.5, 1, 3, 5]] Outputs: y: shape=(2, 4), dtype=bfloat16 [[-2.07812, -0.691406, 0, 0.222656], [0.40625, 0.691406, 1.38281, 1.78906]] **test_cc_supported_dtype_Log1p_finite_float16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(2, 4), dtype=float16 [[-0.875, -0.5 , 0. , 0.25 ], [ 0.5 , 1. , 3. , 5. ]] Outputs: y: shape=(2, 4), dtype=float16 [[-2.08 , -0.6934, 0. , 0.2231], [ 0.4055, 0.6934, 1.387 , 1.792 ]] **test_cc_supported_dtype_Log1p_finite_float32** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(2, 4), dtype=float32 [[-0.875, -0.5 , 0. , 0.25 ], [ 0.5 , 1. , 3. , 5. ]] Outputs: y: shape=(2, 4), dtype=float32 [[-2.0794415 , -0.6931472 , 0. , 0.22314355], [ 0.4054651 , 0.6931472 , 1.3862944 , 1.7917595 ]] **test_cc_supported_dtype_Log1p_finite_float64** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(2, 4), dtype=float64 [[-0.875, -0.5 , 0. , 0.25 ], [ 0.5 , 1. , 3. , 5. ]] Outputs: y: shape=(2, 4), dtype=float64 [[-2.07944154, -0.69314718, 0. , 0.22314355], [ 0.40546511, 0.69314718, 1.38629436, 1.79175947]] **test_cc_supported_dtype_Log1p_near_minus_one_bfloat16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(2,), dtype=bfloat16 [-0.992188, -0.9375] Outputs: y: shape=(2,), dtype=bfloat16 [-4.84375, -2.76562] **test_cc_supported_dtype_Log1p_near_minus_one_float16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(2,), dtype=float16 [-0.992 , -0.9375] Outputs: y: shape=(2,), dtype=float16 [-4.85 , -2.773] **test_cc_supported_dtype_Log1p_near_minus_one_float32** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(2,), dtype=float32 [-0.9921875, -0.9375 ] Outputs: y: shape=(2,), dtype=float32 [-4.8520303, -2.7725887] **test_cc_supported_dtype_Log1p_near_minus_one_float64** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(2,), dtype=float64 [-0.9921875, -0.9375 ] Outputs: y: shape=(2,), dtype=float64 [-4.85203026, -2.77258872] **test_cc_supported_dtype_Log1p_scalar_bfloat16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(), dtype=bfloat16 1 Outputs: y: shape=(), dtype=bfloat16 0.691406 **test_cc_supported_dtype_Log1p_scalar_float16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(), dtype=float16 1. Outputs: y: shape=(), dtype=float16 0.6934 **test_cc_supported_dtype_Log1p_scalar_float32** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(), dtype=float32 1. Outputs: y: shape=(), dtype=float32 0.6931472 **test_cc_supported_dtype_Log1p_scalar_float64** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(), dtype=float64 1. Outputs: y: shape=(), dtype=float64 0.69314718 **test_cc_supported_dtype_Log1p_small_inputs_bfloat16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(4,), dtype=bfloat16 [-0.000976562, -0, 0, 0.000976562] Outputs: y: shape=(4,), dtype=bfloat16 [-0.000976562, -0, 0, 0.000976562] **test_cc_supported_dtype_Log1p_small_inputs_float16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(4,), dtype=float16 [-6.104e-05, -0.000e+00, 0.000e+00, 6.104e-05] Outputs: y: shape=(4,), dtype=float16 [-6.104e-05, -0.000e+00, 0.000e+00, 6.104e-05] **test_cc_supported_dtype_Log1p_small_inputs_float32** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(4,), dtype=float32 [-1.e-08, -0.e+00, 0.e+00, 1.e-08] Outputs: y: shape=(4,), dtype=float32 [-1.e-08, -0.e+00, 0.e+00, 1.e-08] **test_cc_supported_dtype_Log1p_small_inputs_float64** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(4,), dtype=float64 [-1.e-20, -0.e+00, 0.e+00, 1.e-20] Outputs: y: shape=(4,), dtype=float64 [-1.e-20, -0.e+00, 0.e+00, 1.e-20] **test_cc_supported_dtype_Log1p_special_values_bfloat16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(7,), dtype=bfloat16 [-0, 0, -1, -2, -inf, inf, nan] Outputs: y: shape=(7,), dtype=bfloat16 [-0, 0, -inf, nan, nan, inf, nan] **test_cc_supported_dtype_Log1p_special_values_float16** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(7,), dtype=float16 [ -0., 0., -1., -2., -inf, inf, nan] Outputs: y: shape=(7,), dtype=float16 [ -0., 0., -inf, nan, nan, inf, nan] **test_cc_supported_dtype_Log1p_special_values_float32** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(7,), dtype=float32 [ -0., 0., -1., -2., -inf, inf, nan] Outputs: y: shape=(7,), dtype=float32 [ -0., 0., -inf, nan, nan, inf, nan] **test_cc_supported_dtype_Log1p_special_values_float64** .. code-block:: text Node: Log1p(x) -> (y) .. code-block:: text Inputs: x: shape=(7,), dtype=float64 [ -0., 0., -1., -2., -inf, inf, nan] Outputs: y: shape=(7,), dtype=float64 [ -0., 0., -inf, nan, nan, inf, nan]