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

Method unix_wrap_single_compile

torch/utils/cpp_extension.py:594–617  ·  view source on GitHub ↗
(obj, src, ext, cc_args, extra_postargs, pp_opts)

Source from the content-addressed store, hash-verified

592 paths[i] = os.path.abspath(paths[i])
593
594 def unix_wrap_single_compile(obj, src, ext, cc_args, extra_postargs, pp_opts) -> None:
595 # Copy before we make any modifications.
596 cflags = copy.deepcopy(extra_postargs)
597 try:
598 original_compiler = self.compiler.compiler_so
599 if _is_cuda_file(src):
600 nvcc = [_join_rocm_home('bin', 'hipcc') if IS_HIP_EXTENSION else _join_cuda_home('bin', 'nvcc')]
601 self.compiler.set_executable('compiler_so', nvcc)
602 if isinstance(cflags, dict):
603 cflags = cflags['nvcc']
604 if IS_HIP_EXTENSION:
605 cflags = COMMON_HIPCC_FLAGS + cflags + _get_rocm_arch_flags(cflags)
606 else:
607 cflags = unix_cuda_flags(cflags)
608 elif isinstance(cflags, dict):
609 cflags = cflags['cxx']
610 if IS_HIP_EXTENSION:
611 cflags = COMMON_HIP_FLAGS + cflags
612 append_std17_if_no_std_present(cflags)
613
614 original_compile(obj, src, ext, cc_args, cflags, pp_opts)
615 finally:
616 # Put the original compiler back in place.
617 self.compiler.set_executable('compiler_so', original_compiler)
618
619 def unix_wrap_ninja_compile(sources,
620 output_dir=None,

Callers

nothing calls this directly

Calls 5

_is_cuda_fileFunction · 0.85
_join_rocm_homeFunction · 0.85
_join_cuda_homeFunction · 0.85
isinstanceFunction · 0.85
_get_rocm_arch_flagsFunction · 0.85

Tested by

no test coverage detected