MCPcopy Create free account
hub / github.com/pytorch/pytorch / spawn

Method spawn

torch/utils/cpp_extension.py:715–762  ·  view source on GitHub ↗
(cmd)

Source from the content-addressed store, hash-verified

713 extra_postargs = None
714
715 def spawn(cmd):
716 # Using regex to match src, obj and include files
717 src_regex = re.compile('/T(p|c)(.*)')
718 src_list = [
719 m.group(2) for m in (src_regex.match(elem) for elem in cmd)
720 if m
721 ]
722
723 obj_regex = re.compile('/Fo(.*)')
724 obj_list = [
725 m.group(1) for m in (obj_regex.match(elem) for elem in cmd)
726 if m
727 ]
728
729 include_regex = re.compile(r'((\-|\/)I.*)')
730 include_list = [
731 m.group(1)
732 for m in (include_regex.match(elem) for elem in cmd) if m
733 ]
734
735 if len(src_list) >= 1 and len(obj_list) >= 1:
736 src = src_list[0]
737 obj = obj_list[0]
738 if _is_cuda_file(src):
739 nvcc = _join_cuda_home('bin', 'nvcc')
740 if isinstance(self.cflags, dict):
741 cflags = self.cflags['nvcc']
742 elif isinstance(self.cflags, list):
743 cflags = self.cflags
744 else:
745 cflags = []
746
747 cflags = win_cuda_flags(cflags) + ['-std=c++17', '--use-local-env']
748 for flag in COMMON_MSVC_FLAGS:
749 cflags = ['-Xcompiler', flag] + cflags
750 for ignore_warning in MSVC_IGNORE_CUDAFE_WARNINGS:
751 cflags = ['-Xcudafe', '--diag_suppress=' + ignore_warning] + cflags
752 cmd = [nvcc, '-c', src, '-o', obj] + include_list + cflags
753 elif isinstance(self.cflags, dict):
754 cflags = COMMON_MSVC_FLAGS + self.cflags['cxx']
755 append_std17_if_no_std_present(cflags)
756 cmd += cflags
757 elif isinstance(self.cflags, list):
758 cflags = COMMON_MSVC_FLAGS + self.cflags
759 append_std17_if_no_std_present(cflags)
760 cmd += cflags
761
762 return original_spawn(cmd)
763
764 try:
765 self.compiler.spawn = spawn

Callers 14

test_exception_raisesMethod · 0.80
test_signal_raisesMethod · 0.80
_test_process_exitedMethod · 0.80
_test_model_implMethod · 0.80
test_torch_mp_exampleMethod · 0.80
_test_zombie_workflowMethod · 0.80
test_caseMethod · 0.80

Calls 6

_is_cuda_fileFunction · 0.85
_join_cuda_homeFunction · 0.85
isinstanceFunction · 0.85
compileMethod · 0.45
groupMethod · 0.45
matchMethod · 0.45

Tested by 7

test_exception_raisesMethod · 0.64
test_signal_raisesMethod · 0.64
_test_process_exitedMethod · 0.64
_test_model_implMethod · 0.64
test_torch_mp_exampleMethod · 0.64
_test_zombie_workflowMethod · 0.64
test_caseMethod · 0.64