make test_jit infer the profiling mode, add a job for simple executor (#38374)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/38374
Differential Revision: D21567658
Pulled By: Krovatkin
fbshipit-source-id: c0eb44cf6c842d5feebabf8c7d99c1b4aa6c4960
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 8b0e359..c6c45cb 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -2884,6 +2884,14 @@
docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-py3.6-gcc5.4:9a3986fa-7ce7-4a36-a001-3c9bef9892e2"
resource_class: large
- pytorch_linux_test:
+ name: pytorch_linux_xenial_py3_6_gcc5_4_ge_config_simple_test
+ requires:
+ - setup
+ - pytorch_linux_xenial_py3_6_gcc5_4_build
+ build_environment: "pytorch-linux-xenial-py3.6-gcc5.4-ge_config_simple-test"
+ docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-py3.6-gcc5.4:9a3986fa-7ce7-4a36-a001-3c9bef9892e2"
+ resource_class: large
+ - pytorch_linux_test:
name: pytorch_linux_xenial_cuda10_2_cudnn7_py3_ge_config_legacy_test
requires:
- setup
diff --git a/.circleci/verbatim-sources/workflows-pytorch-ge-config-tests.yml b/.circleci/verbatim-sources/workflows-pytorch-ge-config-tests.yml
index 5800490..08aed69 100644
--- a/.circleci/verbatim-sources/workflows-pytorch-ge-config-tests.yml
+++ b/.circleci/verbatim-sources/workflows-pytorch-ge-config-tests.yml
@@ -15,6 +15,14 @@
docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-py3.6-gcc5.4:9a3986fa-7ce7-4a36-a001-3c9bef9892e2"
resource_class: large
- pytorch_linux_test:
+ name: pytorch_linux_xenial_py3_6_gcc5_4_ge_config_simple_test
+ requires:
+ - setup
+ - pytorch_linux_xenial_py3_6_gcc5_4_build
+ build_environment: "pytorch-linux-xenial-py3.6-gcc5.4-ge_config_simple-test"
+ docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-py3.6-gcc5.4:9a3986fa-7ce7-4a36-a001-3c9bef9892e2"
+ resource_class: large
+ - pytorch_linux_test:
name: pytorch_linux_xenial_cuda10_2_cudnn7_py3_ge_config_legacy_test
requires:
- setup
diff --git a/test/test_jit_simple.py b/test/test_jit_simple.py
index e3fa878..910e4a1 100644
--- a/test/test_jit_simple.py
+++ b/test/test_jit_simple.py
@@ -4,6 +4,7 @@
if __name__ == '__main__':
run_tests()
- import test_jit_py3
- suite = unittest.findTestCases(test_jit_py3)
- unittest.TextTestRunner().run(suite)
+ if not PY2:
+ import test_jit_py3
+ suite = unittest.findTestCases(test_jit_py3)
+ unittest.TextTestRunner().run(suite)
diff --git a/torch/testing/_internal/common_utils.py b/torch/testing/_internal/common_utils.py
index 8a28032..5b4cc35 100644
--- a/torch/testing/_internal/common_utils.py
+++ b/torch/testing/_internal/common_utils.py
@@ -58,6 +58,20 @@
SIMPLE = 2
PROFILING = 3
+def cppProfilingFlagsToProfilingMode():
+ old_prof_exec_state = torch._C._jit_set_profiling_executor(True)
+ old_prof_mode_state = torch._C._jit_set_profiling_mode(True)
+ torch._C._jit_set_profiling_executor(old_prof_exec_state)
+ torch._C._jit_set_profiling_mode(old_prof_mode_state)
+
+ if old_prof_exec_state:
+ if old_prof_mode_state:
+ return ProfilingMode.PROFILING
+ else:
+ return ProfilingMode.SIMPLE
+ else:
+ return ProfilingMode.LEGACY
+
@contextmanager
def enable_profiling_mode_for_profiling_tests():
if GRAPH_EXECUTOR == ProfilingMode.PROFILING:
@@ -126,14 +140,17 @@
parser.add_argument('--log-suffix', type=str, default="")
parser.add_argument('--run-parallel', type=int, default=1)
-GRAPH_EXECUTOR = ProfilingMode.SIMPLE if IS_SANDCASTLE else ProfilingMode.PROFILING
args, remaining = parser.parse_known_args()
if args.ge_config == 'legacy':
GRAPH_EXECUTOR = ProfilingMode.LEGACY
elif args.ge_config == 'profiling':
GRAPH_EXECUTOR = ProfilingMode.PROFILING
-else:
+elif args.ge_config == 'simple':
GRAPH_EXECUTOR = ProfilingMode.SIMPLE
+else:
+ # infer flags based on the default settings
+ GRAPH_EXECUTOR = cppProfilingFlagsToProfilingMode()
+
LOG_SUFFIX = args.log_suffix
RUN_PARALLEL = args.run_parallel