mindspore.ops.NextAfter
- class mindspore.ops.NextAfter[source]
Returns the next representable floating-point value after x1 towards x2 element-wise.
Say there are two float32 numbers \(a, b\), and let the representable delta of float32 datatype is \(eps\). If \(a < b\), then the next representable of \(a\) towards \(b\) is \(a+eps\), If \(a > b\), the next representable of \(a\) towards \(b\) is \(a-eps\).
\[out_{i} = nextafter({x1_{i}, x2_{i}})\]Warning
This is an experimental API that is subject to change or deletion.
- Inputs:
x1 (Tensor) - The shape of tensor is \((N,*)\) where \(*\) means, any number of additional dimensions. Must be one of the following types: float32, float64.
x2 (Tensor) - The shape of tensor is \((N,*)\) where \(*\) means, any number of additional dimensions. Must be one of the following types: float32, float64.
- Outputs:
Tensor, has the same shape and data type as x1.
- Raises
TypeError – If neither x1 nor x2 is a Tensor.
TypeError – If the dtype of x1 and x2 is not one of: float32, float64.
TypeError – If the dtypes of x1 and x2 are not same.
ValueError – If x1’s shape is not the same as x2.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> nextafter = ops.NextAfter() >>> x1 = Tensor(np.asarray([0.0]), mindspore.float32) >>> x2 = Tensor(np.asarray([0.1]), mindspore.float32) >>> output = nextafter(x1, x2) >>> print(output) [1.e-45]