xref: /aosp_15_r20/external/pytorch/test/inductor/opinfo_harness.py (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1import os
2import subprocess
3
4from torch.testing._internal.common_methods_invocations import op_db
5
6
7if __name__ == "__main__":
8    i = 0
9    while i < len(op_db):
10        start = i
11        end = i + 20
12        os.environ["PYTORCH_TEST_RANGE_START"] = f"{start}"
13        os.environ["PYTORCH_TEST_RANGE_END"] = f"{end}"
14        popen = subprocess.Popen(
15            ["pytest", "test/inductor/test_torchinductor_opinfo.py"],
16            stdout=subprocess.PIPE,
17        )
18        for line in popen.stdout:
19            print(line.decode(), end="")
20        popen.stdout.close()
21        return_code = popen.wait()
22        if return_code:
23            raise subprocess.CalledProcessError(
24                return_code, ["pytest", "test/inductor/test_torchinductor_opinfo.py"]
25            )
26        i = end + 1
27