Skip to content
fn

isnan_op

→TensorImplPtr
int isnan_op(const int & a)

Python wrappers

Public Python APIs implemented by this engine symbol.

Element-wise test for NaN values — returns a boolean tensor that is True at every position whose input is NaN.

Not differentiable: returns a detached boolean tensor with no autograd node, regardless of a->requires_grad().

Math

yi=(xi≠xi)y_i = (x_i \ne x_i)

The IEEE-754 property "NaN does not equal itself" defines the predicate.

Shape

Output shape equals input shape (elementwise).

See Also

isinf_op, isfinite_op, nan_to_num_op.

Parameters

aTensorImplPtr
Input tensor of any floating-point dtype. Integer inputs always produce False since no integer encodes NaN.

Returns

TensorImplPtr

Boolean tensor with the same shape and device as a; dtype is Dtype::Bool.

Notes

Useful as a guard inside composite reductions (nanmean, nansum) where NaN-tainted slots must be replaced before accumulation.