Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
apex
Commits
b7025fc9
Commit
b7025fc9
authored
Sep 13, 2018
by
Michael Carilli
Browse files
Skeleton for modular tests
parent
3e1a1c09
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
64 additions
and
3 deletions
+64
-3
tests/run_amp/__init__.py
tests/run_amp/__init__.py
+0
-0
tests/run_amp/test_basic_casts.py
tests/run_amp/test_basic_casts.py
+1
-1
tests/run_amp/test_promotion.py
tests/run_amp/test_promotion.py
+1
-1
tests/run_amp/test_rnn.py
tests/run_amp/test_rnn.py
+1
-1
tests/run_amp/utils.py
tests/run_amp/utils.py
+0
-0
tests/run_fp16_optimizer/__init__.py
tests/run_fp16_optimizer/__init__.py
+0
-0
tests/run_fp16_optimizer/test_fp16_optimizer.py
tests/run_fp16_optimizer/test_fp16_optimizer.py
+41
-0
tests/run_test.py
tests/run_test.py
+20
-0
No files found.
apex/amp/test
/__init__.py
→
tests/run_amp
/__init__.py
View file @
b7025fc9
File moved
apex/amp/test
/test_basic_casts.py
→
tests/run_amp
/test_basic_casts.py
View file @
b7025fc9
...
@@ -8,7 +8,7 @@ import torch
...
@@ -8,7 +8,7 @@ import torch
from
torch
import
nn
from
torch
import
nn
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
from
.
utils
import
common_init
,
HALF
,
FLOAT
,
\
from
utils
import
common_init
,
HALF
,
FLOAT
,
\
ALWAYS_HALF
,
ALWAYS_FLOAT
,
MATCH_INPUT
ALWAYS_HALF
,
ALWAYS_FLOAT
,
MATCH_INPUT
def
run_layer_test
(
test_case
,
fns
,
expected
,
input_shape
,
test_backward
=
True
):
def
run_layer_test
(
test_case
,
fns
,
expected
,
input_shape
,
test_backward
=
True
):
...
...
apex/amp/test
/test_promotion.py
→
tests/run_amp
/test_promotion.py
View file @
b7025fc9
...
@@ -7,7 +7,7 @@ import torch
...
@@ -7,7 +7,7 @@ import torch
from
torch
import
nn
from
torch
import
nn
import
torch.nn.functional
as
F
import
torch.nn.functional
as
F
from
.
utils
import
common_init
,
HALF
,
FLOAT
,
DTYPES
from
utils
import
common_init
,
HALF
,
FLOAT
,
DTYPES
class
TestPromotion
(
unittest
.
TestCase
):
class
TestPromotion
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
...
apex/amp/test
/test_rnn.py
→
tests/run_amp
/test_rnn.py
View file @
b7025fc9
...
@@ -5,7 +5,7 @@ import random
...
@@ -5,7 +5,7 @@ import random
import
torch
import
torch
from
torch
import
nn
from
torch
import
nn
from
.
utils
import
common_init
,
HALF
from
utils
import
common_init
,
HALF
class
TestRnnCells
(
unittest
.
TestCase
):
class
TestRnnCells
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
...
apex/amp/test
/utils.py
→
tests/run_amp
/utils.py
View file @
b7025fc9
File moved
tests/run_fp16_optimizer/__init__.py
0 → 100644
View file @
b7025fc9
tests/run_fp16_optimizer/test_fp16_optimizer.py
0 → 100644
View file @
b7025fc9
import
unittest
import
functools
as
ft
import
itertools
as
it
import
torch
from
apex.fp16_utils
import
FP16_Optimizer
class
TestFP16Optimizer
(
unittest
.
TestCase
):
def
setUp
(
self
):
N
,
D_in
,
D_out
=
64
,
1024
,
16
self
.
N
=
N
self
.
D_in
=
D_in
self
.
D_out
=
D_out
self
.
x
=
torch
.
randn
((
N
,
D_in
),
dtype
=
torch
.
float16
,
device
=
'cuda'
)
self
.
y
=
torch
.
randn
((
N
,
D_out
),
dtype
=
torch
.
float16
,
device
=
'cuda'
)
self
.
model
=
torch
.
nn
.
Linear
(
D_in
,
D_out
).
cuda
().
half
()
# def tearDown(self):
# pass
def
test_minimal
(
self
):
pass
def
test_minimal_static
(
self
):
pass
def
test_minimal_dynamic
(
self
):
pass
def
test_closure
(
self
):
pass
def
test_closure_dynamic
(
self
):
pass
def
test_save_load
(
self
):
pass
if
__name__
==
'__main__'
:
unittest
.
main
()
tests/run_test.py
0 → 100644
View file @
b7025fc9
import
unittest
import
sys
test_dirs
=
[
"run_fp16_optimizer"
,
"run_amp"
]
runner
=
unittest
.
TextTestRunner
(
verbosity
=
2
)
errcode
=
0
for
test_dir
in
test_dirs
:
suite
=
unittest
.
TestLoader
().
discover
(
test_dir
)
print
(
"
\n
Executing tests from "
+
test_dir
)
result
=
runner
.
run
(
suite
)
if
not
result
.
wasSuccessful
():
errcode
=
1
sys
.
exit
(
errcode
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment