Skip to content
Draft
2 changes: 1 addition & 1 deletion related_commits
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ubuntu|pytorch|apex|release/1.12.0|7e4aca37812b99e9c3e302d7d1d2e37ad6377f8c|https://github.com/ROCm/apex
ubuntu|pytorch|torchvision|release/0.27|b3d5b111f54044b216013162706ca107aa7a4ec4|https://github.com/ROCm/vision
ubuntu|pytorch|torchaudio|main|c0cbdb95674556cdff7266f2d44bb855f634cfde|https://github.com/pytorch/audio
ubuntu|pytorch|torchaudio|ew/rocm-24803-hipify-gpu-ext|0c7509ef5eae0ad822d2099ca5b42fce18db0148|https://github.com/ethanwee1/audio
9 changes: 8 additions & 1 deletion torch/utils/cpp_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,13 +1493,20 @@ def CUDAExtension(name, sources, *args, **kwargs):
)

hipified_sources = set()
# Resolve build_dir through realpath so that a Windows subst/virtual
# drive (e.g. a B: that aliases a directory on C:) matches the
# canonicalized source paths returned by hipify. Without this,
# os.path.relpath() below can raise "path is on mount 'C:', start on
# mount 'B:'" when os.getcwd() reports the alias but the hipified
# source resolves to the underlying drive.
build_dir_real = os.path.realpath(build_dir)
for source in sources:
s_abs = os.path.abspath(source)
hipified_s_abs = (hipify_result[s_abs].hipified_path if (s_abs in hipify_result and
hipify_result[s_abs].hipified_path is not None) else s_abs)
# setup() arguments must *always* be /-separated paths relative to the setup.py directory,
# *never* absolute paths
hipified_sources.add(os.path.relpath(hipified_s_abs, build_dir))
hipified_sources.add(os.path.relpath(os.path.realpath(hipified_s_abs), build_dir_real))

sources = list(hipified_sources)

Expand Down