forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AmpKernels.cpp
41 lines (35 loc) · 1.27 KB
/
AmpKernels.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#define TORCH_ASSERT_ONLY_METHOD_OPERATORS
#include <ATen/native/AmpKernels.h>
#include <ATen/Dispatch.h>
#include <ATen/core/Tensor.h>
#ifndef AT_PER_OPERATOR_HEADERS
#include <ATen/Functions.h>
#include <ATen/NativeFunctions.h>
#else
#include <ATen/ops/_amp_foreach_non_finite_check_and_unscale.h>
#include <ATen/ops/_amp_foreach_non_finite_check_and_unscale_native.h>
#include <ATen/ops/_amp_update_scale.h>
#include <ATen/ops/_amp_update_scale_native.h>
#endif
namespace at::native {
void _amp_foreach_non_finite_check_and_unscale_cpu_(
TensorList scaled_grads,
at::Tensor& found_inf,
const at::Tensor& inv_scale) {
_amp_foreach_non_finite_check_and_unscale_cpu_stub(
found_inf.device().type(), scaled_grads, found_inf, inv_scale);
}
at::Tensor& _amp_update_scale_cpu_ (
at::Tensor& current_scale,
at::Tensor& growth_tracker,
const at::Tensor& found_inf,
double growth_factor,
double backoff_factor,
int64_t growth_interval) {
return _amp_update_scale_cpu_stub(
growth_tracker.device().type(), current_scale, growth_tracker,
found_inf, growth_factor, backoff_factor, growth_interval);
}
DEFINE_DISPATCH(_amp_foreach_non_finite_check_and_unscale_cpu_stub);
DEFINE_DISPATCH(_amp_update_scale_cpu_stub);
} // namespace at::native