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

Function checknonfinite_lower

imperative/python/megengine/xla/rules/math.py:560–567  ·  view source on GitHub ↗
(ctx, *args: Union[HLOTensor, Sequence[HLOTensor]])

Source from the content-addressed store, hash-verified

558
559@register_lower_rule(mops.CheckNonFinite)
560def checknonfinite_lower(ctx, *args: Union[HLOTensor, Sequence[HLOTensor]]):
561 check_inf = [logical_or(isnan(arg), isinf(arg)) for arg in args]
562 check_inf_reduce = [expand_dims(sum(inp), 0) for inp in check_inf]
563 concat_res = concat(check_inf_reduce, 0)
564 if_nonfinite = expand_dims(sum(concat_res), 0).astype(np.int32)
565 res = [arg * ctx.op.scale for arg in args]
566 res.append(if_nonfinite)
567 return res

Callers

nothing calls this directly

Calls 8

logical_orFunction · 0.85
sumFunction · 0.85
isnanFunction · 0.70
isinfFunction · 0.70
expand_dimsFunction · 0.70
concatFunction · 0.70
astypeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected