(d_grads, scale)
| 9 | |
| 10 | # Python stopgap, until we get a future-proof kernel into upstream |
| 11 | def 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 | |
| 18 | class LossScaler(object): |
| 19 | def __init__(self, scale=1.0, dynamic=False): |