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

Function cuda_compile_command

torch/_inductor/codecache.py:2108–2136  ·  view source on GitHub ↗
(
    src_files: List[str],
    dst_file: str,
    dst_file_ext: str,
)

Source from the content-addressed store, hash-verified

2106
2107
2108def cuda_compile_command(
2109 src_files: List[str],
2110 dst_file: str,
2111 dst_file_ext: str,
2112) -> str:
2113 include_paths = _cutlass_include_paths()
2114 cuda_lib_options = _cuda_lib_options()
2115 nvcc_host_compiler_options = _nvcc_host_compiler_options()
2116 nvcc_compiler_options = _nvcc_compiler_options()
2117 options = (
2118 nvcc_compiler_options
2119 + [
2120 f"-Xcompiler {opt}" if "=" in opt else f"-Xcompiler={opt}"
2121 for opt in nvcc_host_compiler_options
2122 ]
2123 + ["-I" + path for path in include_paths]
2124 + cuda_lib_options
2125 )
2126 src_file = " ".join(src_files)
2127 res = ""
2128 if dst_file_ext == "o":
2129 res = f"{_cuda_compiler()} {' '.join(options)} -c -o {dst_file} {src_file}"
2130 elif dst_file_ext == "so":
2131 options.append("-shared")
2132 res = f"{_cuda_compiler()} {' '.join(options)} -o {dst_file} {src_file}"
2133 else:
2134 raise NotImplementedError(f"Unsupported output file suffix {dst_file_ext}!")
2135 log.debug("CUDA command: %s", res)
2136 return res
2137
2138
2139class DLLWrapper:

Callers 2

writeMethod · 0.85
compileMethod · 0.85

Calls 8

_cutlass_include_pathsFunction · 0.85
_cuda_lib_optionsFunction · 0.85
_nvcc_compiler_optionsFunction · 0.85
_cuda_compilerFunction · 0.85
joinMethod · 0.45
appendMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…