mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[OpenReg] Migrate OpenReg Tests from tests/test_openreg.py into torch_openreg/tests (#161917)
**Background:** Almost all the tests in `test/test_openreg.py` are designed for `torch_openreg`, so placing these testcases in the test directory is not a good idea. Instead, they should be moved to the `tests` directory under `torch_openreg`, coordinating these tests with their corresponding functional logic. **How to do:** So how do we verify the quality of the third-party device integration mechanism? We will maintain a `test_openreg` entrypoint in `test/run_test.py`. This entrypoint will install `torch_openreg` and run all the testcases located in `torch_openreg`. As long as all testcases pass, we can guarantee that the out-of-tree backend integration mechanism is available. **Next:** We will also improve `torch_openreg's` test coverage in the future. Pull Request resolved: https://github.com/pytorch/pytorch/pull/161917 Approved by: https://github.com/albanD
This commit is contained in:
@ -920,7 +920,12 @@ def _test_autoload(test_directory, options, enable=True):
|
||||
os.environ.pop("TORCH_DEVICE_BACKEND_AUTOLOAD")
|
||||
|
||||
|
||||
def run_test_with_openreg(test_module, test_directory, options):
|
||||
# test_openreg is designed to run all tests under torch_openreg, which
|
||||
# is an torch backend similar to CUDA or MPS and implemented by using
|
||||
# third-party accelerator integration mechanism. Therefore, if all the
|
||||
# tests under torch_openreg are passing, it can means that the mechanism
|
||||
# mentioned above is working as expected.
|
||||
def test_openreg(test_module, test_directory, options):
|
||||
openreg_dir = os.path.join(
|
||||
test_directory, "cpp_extensions", "open_registration_extension", "torch_openreg"
|
||||
)
|
||||
@ -929,7 +934,16 @@ def run_test_with_openreg(test_module, test_directory, options):
|
||||
return return_code
|
||||
|
||||
with extend_python_path([install_dir]):
|
||||
return run_test(test_module, test_directory, options)
|
||||
cmd = [
|
||||
sys.executable,
|
||||
"-m",
|
||||
"unittest",
|
||||
"discover",
|
||||
"-s",
|
||||
os.path.join(openreg_dir, "tests"),
|
||||
"-v",
|
||||
]
|
||||
return shell(cmd, cwd=test_directory, env=os.environ)
|
||||
|
||||
|
||||
def test_distributed(test_module, test_directory, options):
|
||||
@ -1258,8 +1272,7 @@ CUSTOM_HANDLERS = {
|
||||
"test_ci_sanity_check_fail": run_ci_sanity_check,
|
||||
"test_autoload_enable": test_autoload_enable,
|
||||
"test_autoload_disable": test_autoload_disable,
|
||||
"test_openreg": run_test_with_openreg,
|
||||
"test_transformers_privateuse1": run_test_with_openreg,
|
||||
"test_openreg": test_openreg,
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user