Skip to content

Linspace broken for complex dtypes #38775

@anjali411

Description

@anjali411

Linspace behavior for complex dtypes seems buggy (atleast on the cpu side)
Additionally the document says start and end should be float which should be changed to float or complex (similar comment for logspace as well)

>>> torch.linspace(-10j, 10j, steps=5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: value cannot be converted to type float without overflow: (-0,-10)
>>> torch.from_numpy(numpy.linspace(-10j,10j,4))
tensor([(0.0000-10.0000j), (0.0000-3.3333j), (0.0000+3.3333j), (0.0000+10.0000j)],
       dtype=torch.complex128)

cc @ezyang @anjali411 @dylanbespalko

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: complexRelated to complex number support in PyTorchtriagedThis 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