Skip to content

Inconsistency between torch.abs() and np.absolute() for complex tensors #33567

@anjali411

Description

@anjali411
import torch
>>> a = torch.tensor([1+2j])
tensor([(1.0000 + 2.0000j)], dtype=torch.complex128)
>>> a.abs()
tensor([   (2.2361 + 0.0000j)], dtype=torch.complex128)


import numpy as np
>>> a=np.array([1+2j])
>>> a.dtype
dtype('complex128')
>>> np_res = np.absolute(a)
array([2.23606798])
>>> np_res.dtype
dtype('float64')

cc @ezyang @anjali411 @dylanbespalko

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issuemodule: 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