Bugfix Support npu:x format for Tensor.npu

This commit is contained in:
shaoyf
2022-11-11 09:40:29 +00:00
committed by Gitee
parent 38b321ea66
commit c39619f3b6
+4
View File
@@ -64,6 +64,10 @@ def npu_confusion_transpose(self, perm, shape, transpose_first):
@torch_device_guard
def _npu(self, *args, **kwargs):
if args and isinstance(args[0], str) and 'npu' in args[0]:
args = tuple([list(args)[0].replace('npu', torch_npu.npu.native_device)])
if kwargs and 'npu' in kwargs.get("device", ""):
kwargs['device'] = kwargs['device'].replace("npu", torch_npu.npu.native_device)
return torch_npu._C.npu(self, *args, **kwargs)