Skip to content

addr bug for complex and inefficient implementation  #47313

@ngimel

Description

@ngimel

addr implementation here
https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/LinearAlgebra.cpp#L147-L159
does explicit multiplications by alpha and beta even though by default alpha and beta are 1, so no multiplication is necessary. This degrades performance and memory usage.
In addition, line 55 does invalid cast, so invocation with complex beta results in an error:

a=torch.randn(3, dtype=torch.complex64)                                                                                                                                                                
b=torch.randn(3, dtype=torch.complex64)                                                                                                                                                                
c=torch.randn(3,3, dtype=torch.complex64)   
c.addr(a,b, beta=0+0.1j)
RuntimeError: value cannot be converted to type double without overflow: (0,0.1)

related: #44364
cc @vishwakftw @jianyuh @nikitaved @pearu @mruberry @heitorschueroff
cc @ivannz

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: linear algebraIssues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmultriagedThis 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