[ROCm][Windows] Fix export macros (#144098)

For correct import and export of functions when the dynamic linkage is used for HIP libraries on windows, the appropriate export/import macros need to be put in place. This Pull Request utilizes existing CUDA import/export macros by converting them to corresponding HIP macros during the hipification process.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/144098
Approved by: https://github.com/jeffdaily
This commit is contained in:
Michal Gallus
2025-01-04 17:12:44 +00:00
committed by PyTorch MergeBot
parent 45ef3309e3
commit 93633d0e80
2 changed files with 4 additions and 0 deletions

View File

@ -139,8 +139,10 @@
#endif
#if defined(TORCH_HIP_BUILD_MAIN_LIB)
#define TORCH_HIP_CPP_API C10_EXPORT
#define TORCH_HIP_API C10_EXPORT
#else
#define TORCH_HIP_CPP_API C10_IMPORT
#define TORCH_HIP_API C10_IMPORT
#endif

View File

@ -8422,6 +8422,8 @@ CUDA_SPECIAL_MAP = collections.OrderedDict(
PYTORCH_SPECIFIC_MAPPINGS = collections.OrderedDict(
[
("USE_CUDA", ("USE_ROCM", API_PYTORCH)),
("TORCH_CUDA_CPP_API", ("TORCH_HIP_CPP_API", API_PYTORCH)),
("TORCH_CUDA_CU_API", ("TORCH_HIP_API", API_PYTORCH)),
("CUDA_VERSION", ("TORCH_HIP_VERSION", API_PYTORCH)),
("cudaHostAllocator", ("hipHostAllocator", API_PYTORCH)),
("cudaDeviceAllocator", ("hipDeviceAllocator", API_PYTORCH)),