DEV Community

han
han

Posted on

torch.abs can not be executed in NPU device

Abstract

The torch.abs command will throw an error when the device is NPU and the parameter is set to compiler.The error message is as follows:


RuntimeError: abs:build/CMakeFiles/torch_npu.dir/compiler_depend.ts:216 NPU function error: call aclnnAbs failed, error code is 161002
[ERROR] 2026-01-08-16:48:46 (PID:18801, Device:0, RankID:-1) ERR00100 PTA call acl api failed.
[PID: 18801] 2026-01-08-16:48:46.230.433 AclNN_Parameter_Error(EZ1001): Tensor self not implemented for DT_COMPLEX64, should be in dtype support list [DT_DOUBLE,DT_FLOAT,DT_FLOAT16,DT_INT64,DT_INT32,DT_INT16,DT_INT8,DT_UINT8,DT_BOOL,DT_BFLOAT16,].


Enter fullscreen mode Exit fullscreen mode

Solution

We can use torch.sqrt instead of torch.abs, as blow:


# abs_val = torch.abs(z)
abs_val = torch.sqrt(z.real**2 + z.imag**2)

Enter fullscreen mode Exit fullscreen mode

Top comments (0)