mindspore.ops.nextafter
- mindspore.ops.nextafter(input, other)[source]
Returns the next representable floating-point value after input towards other 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\), the next representable of \(b\) towards \(a\) is \(b-eps\).
\[out_{i} = nextafter({input_{i}, other_{i}})\]- Parameters
input (Tensor) – The first input tensor. The shape of tensor is \((N,*)\) where \(*\) means, any number of additional dimensions. Must be one of the following types: float32, float64.
other (Tensor) – The second input tensor. The shape of tensor is \((N,*)\) where \(*\) means, any number of additional dimensions. Must be one of the following types: float32, float64.
- Returns
Tensor, has the same shape and data type as input.
- Raises
TypeError – If neither input nor other is a Tensor.
TypeError – If the dtype of input and other is not one of: float32, float64.
TypeError – If the dtypes of input and other are not same.
ValueError – If input’s shape is not the same as other.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor, ops >>> input_ = Tensor(np.asarray([0.0]), mindspore.float32) >>> other_ = Tensor(np.asarray([0.1]), mindspore.float32) >>> output_ = ops.nextafter(input_, other_) >>> print(output_) [1.e-45]