mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Enable Windows tests (#146666)
Fixes #ISSUE_NUMBER Pull Request resolved: https://github.com/pytorch/pytorch/pull/146666 Approved by: https://github.com/albanD
This commit is contained in:
@ -3,13 +3,13 @@
|
||||
import os
|
||||
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from torch.testing._internal.common_utils import (
|
||||
IS_WINDOWS,
|
||||
run_tests,
|
||||
slowTest,
|
||||
TemporaryFileName,
|
||||
TestCase,
|
||||
)
|
||||
|
||||
@ -23,11 +23,13 @@ class TestFunctionalAutogradBenchmark(TestCase):
|
||||
# The temporary file is exclusively open by this process and the child process
|
||||
# is not allowed to open it again. As this is a simple smoke test, we choose for now
|
||||
# not to run this on windows and keep the code here simple.
|
||||
with tempfile.NamedTemporaryFile() as out_file:
|
||||
with TemporaryFileName() as out_file:
|
||||
cmd = [
|
||||
"python3",
|
||||
"../benchmarks/functional_autograd_benchmark/functional_autograd_benchmark.py",
|
||||
]
|
||||
if IS_WINDOWS:
|
||||
cmd[0] = "python"
|
||||
# Only run the warmup
|
||||
cmd += ["--num-iters", "0"]
|
||||
# Only run the vjp task (fastest one)
|
||||
@ -35,21 +37,16 @@ class TestFunctionalAutogradBenchmark(TestCase):
|
||||
# Only run the specified model
|
||||
cmd += ["--model-filter", model]
|
||||
# Output file
|
||||
cmd += ["--output", out_file.name]
|
||||
cmd += ["--output", out_file]
|
||||
if disable_gpu:
|
||||
cmd += ["--gpu", "-1"]
|
||||
|
||||
res = subprocess.run(cmd)
|
||||
res = subprocess.run(cmd, check=False)
|
||||
|
||||
self.assertTrue(res.returncode == 0)
|
||||
# Check that something was written to the file
|
||||
out_file.seek(0, os.SEEK_END)
|
||||
self.assertTrue(out_file.tell() > 0)
|
||||
self.assertTrue(os.stat(out_file).st_size > 0)
|
||||
|
||||
@unittest.skipIf(
|
||||
IS_WINDOWS,
|
||||
"NamedTemporaryFile on windows does not have all the features we need.",
|
||||
)
|
||||
@unittest.skipIf(
|
||||
PYTORCH_COLLECT_COVERAGE,
|
||||
"Can deadlocks with gcov, see https://github.com/pytorch/pytorch/issues/49656",
|
||||
|
Reference in New Issue
Block a user