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
ced59fcc
Commit
ced59fcc
authored
Aug 09, 2022
by
hubertlu-tw
Browse files
Update L0 unit test script
parent
8a8eb34f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
0 deletions
+77
-0
tests/L0/run_test.py
tests/L0/run_test.py
+77
-0
No files found.
tests/L0/run_test.py
View file @
ced59fcc
"""
import unittest
import sys
...
...
@@ -28,3 +29,79 @@ for test_dir in test_dirs:
errcode = 1
sys.exit(errcode)
"""
############################################################
"""L0 Tests Runner.
How to run this script?
1. Run all the tests: `python /path/to/apex/tests/L0/run_test.py`
2. Run one of the tests (e.g. fused layer norm):
`python /path/to/apex/tests/L0/run_test.py --include run_fused_layer_norm`
3. Run two or more of the tests (e.g. optimizers and fused layer norm):
`python /path/to/apex/tests/L0/run_test.py --include run_optimizers run_fused_layer_norm`
"""
import
argparse
import
os
import
unittest
import
sys
from
apex.testing.common_utils
import
TEST_WITH_ROCM
from
apex.testing.common_utils
import
SKIP_FLAKY_TEST
TEST_ROOT
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
TEST_DIRS
=
[
"run_amp"
,
"run_fp16util"
,
"run_optimizers"
,
"run_fused_layer_norm"
,
"run_mlp"
,
"run_transformer"
,
# not fully supported on ROCm
]
DEFAULT_TEST_DIRS
=
[
"run_amp"
,
"run_fp16util"
,
"run_optimizers"
,
"run_fused_layer_norm"
,
"run_mlp"
,
]
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
description
=
"L0 test runner"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
,
)
parser
.
add_argument
(
"--include"
,
nargs
=
"+"
,
choices
=
TEST_DIRS
,
default
=
DEFAULT_TEST_DIRS
,
help
=
"select a set of tests to run (defaults to ALL tests)."
,
)
args
,
_
=
parser
.
parse_known_args
()
return
args
def
main
(
args
):
runner
=
unittest
.
TextTestRunner
(
verbosity
=
2
)
errcode
=
0
for
test_dir
in
args
.
include
:
test_dir
=
os
.
path
.
join
(
TEST_ROOT
,
test_dir
)
print
(
test_dir
)
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
)
if
__name__
==
'__main__'
:
args
=
parse_args
()
main
(
args
)
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