8000 A Strange type properties in pytorch math function · Issue #65685 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content
A Strange type properties in pytorch math function #65685
@MARD1NO

Description

@MARD1NO

🐛 Bug

Hi, I found a strange type properties in math function like torch.add, torch.mul etc.

x_tensor = torch.ones((3, ), dtype=torch.int8)
y_tensor = torch.tensor(1, dtype=torch.float64)
out = torch.mul(x_tensor, y_tensor) # torch.float64
x_tensor = torch.ones((3, ), dtype=torch.int8)
y_tensor = torch.tensor(1, dtype=torch.int64)
out = torch.mul(x_tensor, y_tensor) # torch.int8
x_tensor = torch.ones((3, 3), dtype=torch.int8)
y_tensor = torch.ones((3, 3), dtype=torch.int64)
out = torch.mul(x_tensor, y_tensor) # torch.int64
x_tensor = torch.ones((3, 3), dtype=torch.int8)
out = torch.mul(x_tensor, 9223372036854775807) # torch.int8

Expected behavior

I think in each case the output tensor should be cast the higher priority dtype.

Environment

  • PyTorch Version (e.g., 1.0): 1.9.0
  • OS (e.g., Linux): mac os
  • How you installed PyTorch (conda, pip, source): pip install
  • Python version: 3.9.0

cc @nairbv @mruberry

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: type promotionRelated to semantics of type promotiontriagedThis 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

      0