Closed
Description
According to v2022.12 (and v2023.12) of the array API standard, the special cases of sign
include:
For real-valued operands... If x_i is NaN, the result is NaN.
However,
from array_api_compat import numpy as np, cupy as cp, torch
np.sign(np.asarray(np.nan)) # nan
cp.sign(cp.asarray(cp.nan)) # array( 0.000e+00)
torch.sign(torch.asarray(torch.nan)) # tensor(0.)
There may be other special cases that are not yet implemented. I haven't done a complete review, but I noticed that torch
gives an error when the input is complex.
torch.sign(torch.asarray(1+1j))
# RuntimeError: Unlike NumPy, torch.sign is not intended to support complex numbers. Please use torch.sgn instead.
Metadata
Metadata
Assignees
Labels
No labels