Python wrappers
Public Python APIs implemented by this engine symbol.Autograd node for nan_to_num — finite values pass through, NaN and the infinities are replaced by the three scalars.
Math
The replaced slots are constants, so they carry no gradient; everywhere
else the op is the identity. This is the reference framework's rule, and
it used to be missing: the op returned a detached tensor, so
nan_to_num(x) + x differentiated to 1 instead of 2 — silently.
See Also
nan_to_num_op, ClipBackward.
Notes
The three scalars are recorded on the trace (scope.set_attr) for the
compile path; the gradient needs only the saved input.
Static methods
1static
forward
→TensorImplPtrint forward(const int & a, double nan_val, double posinf_val, double neginf_val)Forward — replaces NaN / +inf / -inf and wires the backward node.
Parameters
aconst TensorImplPtr&Input tensor.
nan_ val, posinf_ val, neginf_ valdoubleReplacements for NaN, +inf and -inf.
Returns
TensorImplPtrTensor of the input's shape, dtype and device.