Skip to content

torch.sign doesn't work for complex tensors #36323

@anjali411

Description

@anjali411

Numpy:

>>> import numpy as np
>>> np.sign(np.array([1+2j]))
array([1.+0.j])

From numpy docs: For complex inputs, the sign function returns sign(x.real) + 0j if x.real != 0 else sign(x.imag) + 0j.
complex(nan, 0) is returned for complex nan inputs.

PyTorch

>>> import torch
>>> torch.sign(torch.tensor([1+2j]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: "sign_cpu" not implemented for 'ComplexFloat'

cc. @mruberry

cc @ezyang @anjali411 @dylanbespalko

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: complexRelated to complex number support in PyTorchmodule: numpyRelated to numpy support, and also numpy compatibility of our operatorstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions