Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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