-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Change --device=cpu to --ref=cpu 2. Add --mode=quick to test only one shape for CI cpu tests. 3. Add scalar shape for pointwise_dynamic op tests 4. Move assert_close and assert_equal to flag_gems.testing 5. Add mark for each op test, and register it to pytest.ini 6. Add speedup in benchmark print result. --------- Co-authored-by: zhengyang <[email protected]>
- Loading branch information
1 parent
f721fd7
commit 8536ebb
Showing
21 changed files
with
308 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[pytest] | ||
testpaths = tests | ||
pythonpath = src | ||
filterwarnings = ignore::pytest.PytestUnknownMarkWarning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import torch | ||
|
||
RESOLUTION = { | ||
torch.bool: 0, | ||
torch.int16: 0, | ||
torch.int32: 0, | ||
torch.float16: 1e-3, | ||
torch.float32: 1.3e-6, | ||
torch.bfloat16: 0.016, | ||
} | ||
|
||
|
||
def assert_close(res, ref, dtype, equal_nan=False, reduce_dim=1): | ||
assert res.dtype == dtype | ||
ref = ref.to(dtype) | ||
atol = 1e-4 * reduce_dim | ||
rtol = RESOLUTION[dtype] | ||
torch.testing.assert_close(res, ref, atol=atol, rtol=rtol, equal_nan=equal_nan) | ||
|
||
|
||
def assert_equal(res, ref): | ||
assert torch.equal(res, ref) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--device", | ||
"--ref", | ||
action="store", | ||
default="cuda", | ||
required=False, | ||
choices=["cuda", "cpu"], | ||
help="device to run reference tests on", | ||
) | ||
parser.addoption( | ||
"--mode", | ||
action="store", | ||
default="normal", | ||
required=False, | ||
choices=["normal", "quick"], | ||
help="run tests on normal or quick mode", | ||
) | ||
|
||
|
||
def pytest_configure(config): | ||
value = config.getoption("--device") | ||
global TO_CPU | ||
TO_CPU = value == "cpu" | ||
TO_CPU = config.getoption("--ref") == "cpu" | ||
|
||
global QUICK_MODE | ||
QUICK_MODE = config.getoption("--mode") == "quick" |
Oops, something went wrong.