cosdt / torch_backend

https://cosdt.github.io/torch_backend/
Other
3 stars 0 forks source link

[Deivce][DeivceGuard] Solutions for refactoring #8

Open shink opened 4 months ago

shink commented 4 months ago

1. NPUFunctions.h

  1. 参考 CUDA 实现:https://github.com/pytorch/pytorch/blob/main/c10/cuda/CUDAFunctions.cpp,API和实现逻辑尽量与其保持一致
  2. ACL 和 CUDA API 的差异单独抽取一层,使 NPUFunctionsCUDAFunctions 尽量保持高度一致

    比如:aclrtGetDevice()cudaGetDevice() 存在差异,后者可直接获取当前设备,而前者在返回 ACL_ERROR_RT_CONTEXT_NULL 错误码时也是正常的,此错误码表示先前尚未 SetDevice 或创建 Context CANN 文档:https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/80RC2alpha003/apiref/appdevgapi/aclcppdevg_03_0040.html