MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / scale_check_overflow

Function scale_check_overflow

PATH/core/fp16/scaler.py:11–16  ·  view source on GitHub ↗
(d_grads, scale)

Source from the content-addressed store, hash-verified

9
10# Python stopgap, until we get a future-proof kernel into upstream
11def scale_check_overflow(d_grads, scale):
12 any_infinite = ((d_grads != d_grads) | (d_grads.abs() == inf)).any()
13 if any_infinite:
14 return True
15 d_grads.mul_(scale)
16 return False
17
18class LossScaler(object):
19 def __init__(self, scale=1.0, dynamic=False):

Callers 1

unscale_and_updateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected