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

Function include_paths

torch/utils/cpp_extension.py:1144–1175  ·  view source on GitHub ↗

Get the include paths required to build a C++ or CUDA extension. Args: cuda: If `True`, includes CUDA-specific include paths. Returns: A list of include path strings.

(cuda: bool = False)

Source from the content-addressed store, hash-verified

1142
1143
1144def include_paths(cuda: bool = False) -> List[str]:
1145 """
1146 Get the include paths required to build a C++ or CUDA extension.
1147
1148 Args:
1149 cuda: If `True`, includes CUDA-specific include paths.
1150
1151 Returns:
1152 A list of include path strings.
1153 """
1154 lib_include = os.path.join(_TORCH_PATH, 'include')
1155 paths = [
1156 lib_include,
1157 # Remove this once torch/torch.h is officially no longer supported for C++ extensions.
1158 os.path.join(lib_include, 'torch', 'csrc', 'api', 'include'),
1159 # Some internal (old) Torch headers don't properly prefix their includes,
1160 # so we need to pass -Itorch/lib/include/TH as well.
1161 os.path.join(lib_include, 'TH'),
1162 os.path.join(lib_include, 'THC')
1163 ]
1164 if cuda and IS_HIP_EXTENSION:
1165 paths.append(os.path.join(lib_include, 'THH'))
1166 paths.append(_join_rocm_home('include'))
1167 elif cuda:
1168 cuda_home_include = _join_cuda_home('include')
1169 # if we have the Debian/Ubuntu packages for cuda, we get /usr as cuda home.
1170 # but gcc doesn't like having /usr/include passed explicitly
1171 if cuda_home_include != '/usr/include':
1172 paths.append(cuda_home_include)
1173 if CUDNN_HOME is not None:
1174 paths.append(os.path.join(CUDNN_HOME, 'include'))
1175 return paths
1176
1177
1178def library_paths(cuda: bool = False) -> List[str]:

Callers 3

CppExtensionFunction · 0.85
CUDAExtensionFunction · 0.85

Calls 4

_join_rocm_homeFunction · 0.85
_join_cuda_homeFunction · 0.85
joinMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…