Skip to content

In correct torch.baddbmm when beta=0 #52

@roastduck

Description

@roastduck

Quoated from the PyTorch doc:

If beta is 0, then input will be ignored, and nan and inf in it will not be propagated.

But torch_musa propagates nan.

>>> import torch              
>>> import torch_musa         
>>> dev = torch.device('musa')
>>> inp = torch.full((8, 8, 8), float('nan'), dtype=torch.float16).to(dev)
>>> batch1 = torch.zeros((8, 8, 8), dtype=torch.float16).to(dev)          
>>> batch2 = torch.zeros((8, 8, 8), dtype=torch.float16).to(dev)          
>>> torch.baddbmm(inp, batch1, batch2, beta=0)                            
tensor([[[nan, nan, nan, nan, nan, nan, nan, nan],                        
         [nan, nan, nan, nan, nan, nan, nan, nan],                        
         [nan, nan, nan, nan, nan, nan, nan, nan],                        
         [nan, nan, nan, nan, nan, nan, nan, nan],                        
         [nan, nan, nan, nan, nan, nan, nan, nan],                        
         [nan, nan, nan, nan, nan, nan, nan, nan],                        
         [nan, nan, nan, nan, nan, nan, nan, nan],                        
         [nan, nan, nan, nan, nan, nan, nan, nan]],                       

(more outputs are omitted)

Tested with torch_musa 1.1.0+fb1871f.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions