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
| // Copyright (c) Microsoft Corporation. All rights reserved.
| // Licensed under the MIT License.
|
| #pragma once
|
| #include <functional>
| #include <type_traits>
| #include <unordered_map>
|
| namespace onnxruntime {
| namespace training {
|
| enum class OptimizerOutputKey : int {
| GradientAccumulation,
| GradientAllIsFinite,
| GlobalGradientNorm,
| DeltaAllIsFinite,
| };
|
| struct OptimizerOutputKeyHash {
| size_t operator()(OptimizerOutputKey key) const {
| using underlying_type = std::underlying_type<OptimizerOutputKey>::type;
| return std::hash<underlying_type>{}(static_cast<underlying_type>(key));
| }
| };
|
| template <typename T>
| using OptimizerOutputKeyMap =
| std::unordered_map<OptimizerOutputKey, T, OptimizerOutputKeyHash>;
|
| } // namespace training
| } // namespace onnxruntime
|
|