HIP (ROCm) semantics
ROCm™ is AMD’s open source software platform for GPU-accelerated high performance computing and machine learning. HIP is ROCm’s C++ dialect designed to ease conversion of CUDA applications to portable C++ code. HIP is used when converting existing CUDA applications like PyTorch to portable C++ and for new projects that require portability between AMD and NVIDIA.
HIP Interfaces Reuse the CUDA Interfaces
PyTorch for HIP intentionally reuses the existing torch.cuda interfaces.
This helps to accelerate the porting of existing PyTorch code and models because
very few code changes are necessary, if any.
The example from CUDA semantics will work exactly the same for HIP: