Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer div result with wrong data type(shoule be float but got int). #33

Closed
etaf opened this issue Mar 11, 2024 · 1 comment
Closed

Comments

@etaf
Copy link
Contributor

etaf commented Mar 11, 2024

Integer div result with wrong data type(shoule be float but got int).

torch-xpu-ops commit: d19b7f6
Reproduce cases:
diff --git a/test/python/examples/test_binary.py b/test/python/examples/test_binary.py
index 4768a59..352644a 100644
--- a/test/python/examples/test_binary.py
+++ b/test/python/examples/test_binary.py
@@ -41,3 +51,20 @@ class TestSimpleBinary(TestCase):
c_xpu = a_xpu / b_xpu
c_cpu = a_cpu / b_cpu
self.assertEqual(c_cpu, c_xpu.to(cpu_device))
+

  • def test_div_dtype(self, dtype=torch.float):
  •    a_cpu = torch.randint(2, 3, [8, 8])
    
  •    b_cpu = torch.randint(2, 3, [8, 8])
    
  •    a_xpu = a_cpu.to(xpu_device)
    
  •    b_xpu = b_cpu.to(xpu_device)
    
  •    c_xpu = a_xpu / b_xpu
    
  •    c_cpu = a_cpu / b_cpu
    
  •    self.assertEqual(c_cpu.dtype, c_xpu.dtype)
    
  •    self.assertEqual(c_cpu, c_xpu.to(cpu_device))
    
@fengyuan14
Copy link
Contributor

#34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants