Skip to content

Commit 96885f7

Browse files
Krovatkinfacebook-github-bot
authored andcommittedMay 14, 2020
make test_jit infer the profiling mode, add a job for simple executor (pytorch#38374)
Summary: Pull Request resolved: pytorch#38374 Differential Revision: D21567658 Pulled By: Krovatkin fbshipit-source-id: c0eb44cf6c842d5feebabf8c7d99c1b4aa6c4960
1 parent b5868b2 commit 96885f7

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed
 

‎.circleci/config.yml

+8
Original file line numberDiff line numberDiff line change
@@ -2883,6 +2883,14 @@ workflows:
28832883
build_environment: "pytorch-linux-xenial-py3.6-gcc5.4-ge_config_profiling-test"
28842884
docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-py3.6-gcc5.4:9a3986fa-7ce7-4a36-a001-3c9bef9892e2"
28852885
resource_class: large
2886+
- pytorch_linux_test:
2887+
name: pytorch_linux_xenial_py3_6_gcc5_4_ge_config_simple_test
2888+
requires:
2889+
- setup
2890+
- pytorch_linux_xenial_py3_6_gcc5_4_build
2891+
build_environment: "pytorch-linux-xenial-py3.6-gcc5.4-ge_config_simple-test"
2892+
docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-py3.6-gcc5.4:9a3986fa-7ce7-4a36-a001-3c9bef9892e2"
2893+
resource_class: large
28862894
- pytorch_linux_test:
28872895
name: pytorch_linux_xenial_cuda10_2_cudnn7_py3_ge_config_legacy_test
28882896
requires:

‎.circleci/verbatim-sources/workflows-pytorch-ge-config-tests.yml

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
build_environment: "pytorch-linux-xenial-py3.6-gcc5.4-ge_config_profiling-test"
1515
docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-py3.6-gcc5.4:9a3986fa-7ce7-4a36-a001-3c9bef9892e2"
1616
resource_class: large
17+
- pytorch_linux_test:
18+
name: pytorch_linux_xenial_py3_6_gcc5_4_ge_config_simple_test
19+
requires:
20+
- setup
21+
- pytorch_linux_xenial_py3_6_gcc5_4_build
22+
build_environment: "pytorch-linux-xenial-py3.6-gcc5.4-ge_config_simple-test"
23+
docker_image: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-py3.6-gcc5.4:9a3986fa-7ce7-4a36-a001-3c9bef9892e2"
24+
resource_class: large
1725
- pytorch_linux_test:
1826
name: pytorch_linux_xenial_cuda10_2_cudnn7_py3_ge_config_legacy_test
1927
requires:

‎test/test_jit_simple.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
if __name__ == '__main__':
66
run_tests()
7-
import test_jit_py3
8-
suite = unittest.findTestCases(test_jit_py3)
9-
unittest.TextTestRunner().run(suite)
7+
if not PY2:
8+
import test_jit_py3
9+
suite = unittest.findTestCases(test_jit_py3)
10+
unittest.TextTestRunner().run(suite)

‎torch/testing/_internal/common_utils.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ class ProfilingMode(Enum):
5858
SIMPLE = 2
5959
PROFILING = 3
6060

61+
def cppProfilingFlagsToProfilingMode():
62+
old_prof_exec_state = torch._C._jit_set_profiling_executor(True)
63+
old_prof_mode_state = torch._C._jit_set_profiling_mode(True)
64+
torch._C._jit_set_profiling_executor(old_prof_exec_state)
65+
torch._C._jit_set_profiling_mode(old_prof_mode_state)
66+
67+
if old_prof_exec_state:
68+
if old_prof_mode_state:
69+
return ProfilingMode.PROFILING
70+
else:
71+
return ProfilingMode.SIMPLE
72+
else:
73+
return ProfilingMode.LEGACY
74+
6175
@contextmanager
6276
def enable_profiling_mode_for_profiling_tests():
6377
if GRAPH_EXECUTOR == ProfilingMode.PROFILING:
@@ -126,14 +140,17 @@ def _get_test_report_path():
126140
parser.add_argument('--log-suffix', type=str, default="")
127141
parser.add_argument('--run-parallel', type=int, default=1)
128142

129-
GRAPH_EXECUTOR = ProfilingMode.SIMPLE if IS_SANDCASTLE else ProfilingMode.PROFILING
130143
args, remaining = parser.parse_known_args()
131144
if args.ge_config == 'legacy':
132145
GRAPH_EXECUTOR = ProfilingMode.LEGACY
133146
elif args.ge_config == 'profiling':
134147
GRAPH_EXECUTOR = ProfilingMode.PROFILING
135-
else:
148+
elif args.ge_config == 'simple':
136149
GRAPH_EXECUTOR = ProfilingMode.SIMPLE
150+
else:
151+
# infer flags based on the default settings
152+
GRAPH_EXECUTOR = cppProfilingFlagsToProfilingMode()
153+
137154

138155
LOG_SUFFIX = args.log_suffix
139156
RUN_PARALLEL = args.run_parallel

0 commit comments

Comments
 (0)
Please sign in to comment.