fn
nan_to_num_op
→TensorImplPtrint nan_to_num_op(const int & a, double nan_val, double posinf_val, double neginf_val)Python wrappers
Public Python APIs implemented by this engine symbol.Replace NaN and values with user-specified finite substitutes, preserving dtype and shape.
Not differentiable: returns a detached tensor with no backward node. Use only in inference / data-cleaning paths.
Math
\text{nan\_val} & x_i \text{ is NaN} \\ \text{posinf\_val} & x_i = +\infty \\ \text{neginf\_val} & x_i = -\infty \\ x_i & \text{otherwise} \end{cases}$$ **Shape** Output shape equals input shape (elementwise). **See Also** `isnan_op`, `isinf_op`, `isfinite_op`.Parameters
aTensorImplPtrInput tensor of any floating-point dtype. Integer inputs are passed through unchanged (no non-finite values to replace).
nan_valdouble= NoneReplacement for
NaN positions. Default 0.0.posinf_valdouble= NoneReplacement for positions. Default is the maximum finite IEEE-754
float32 value (~3.4028e+38).neginf_valdouble= NoneReplacement for positions. Default is the minimum finite IEEE-754
float32 value (~-3.4028e+38).Returns
TensorImplPtrNew tensor with the same shape, dtype, and device as a; non-finite slots are replaced according to the three scalars.
Notes
The default posinf_val / neginf_val clamp to float32 range
even when a is float64. Pass std::numeric_limits<double>::max
explicitly to preserve double-precision extremes.