Upload apex-master/tests/L0/run_amp/utils.py with huggingface_hub
Browse files
apex-master/tests/L0/run_amp/utils.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
HALF = 'torch.cuda.HalfTensor'
|
| 4 |
+
FLOAT = 'torch.cuda.FloatTensor'
|
| 5 |
+
|
| 6 |
+
DTYPES = [torch.half, torch.float]
|
| 7 |
+
|
| 8 |
+
ALWAYS_HALF = {torch.float: HALF,
|
| 9 |
+
torch.half: HALF}
|
| 10 |
+
ALWAYS_FLOAT = {torch.float: FLOAT,
|
| 11 |
+
torch.half: FLOAT}
|
| 12 |
+
MATCH_INPUT = {torch.float: FLOAT,
|
| 13 |
+
torch.half: HALF}
|
| 14 |
+
|
| 15 |
+
def common_init(test_case):
|
| 16 |
+
test_case.h = 64
|
| 17 |
+
test_case.b = 16
|
| 18 |
+
test_case.c = 16
|
| 19 |
+
test_case.k = 3
|
| 20 |
+
test_case.t = 10
|
| 21 |
+
torch.set_default_tensor_type(torch.cuda.FloatTensor)
|