MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / _check_non_finite

Function _check_non_finite

imperative/python/megengine/functional/math.py:1004–1021  ·  view source on GitHub ↗

r"""Check whether input contains infinite or nan value. Args: inps: tensors to be checked. Returns: a int32 scalar tensor, 0 for False and 1 for True.

(inps: Iterable[Tensor], scale=1.0)

Source from the content-addressed store, hash-verified

1002
1003
1004def _check_non_finite(inps: Iterable[Tensor], scale=1.0) -> Tensor:
1005 r"""Check whether input contains infinite or nan value.
1006
1007 Args:
1008 inps: tensors to be checked.
1009
1010 Returns:
1011 a int32 scalar tensor, 0 for False and 1 for True.
1012 """
1013 if isinstance(inps, Tensor):
1014 inps = [inps]
1015 op = builtin.CheckNonFinite(scale=scale)
1016 oups = apply(op, *inps)
1017 out = oups[-1]
1018 for i in range(len(inps)):
1019 inps[i]._reset(oups[i])
1020
1021 return out

Callers 1

_check_gradientsMethod · 0.85

Calls 3

CheckNonFiniteMethod · 0.80
applyFunction · 0.50
_resetMethod · 0.45

Tested by

no test coverage detected